mercredi 12 septembre 2018

get-content was unexpected at this time - Powershell

I don't know very well Powershell and I ask your help. I have a script to compare first "n" rows (as a parameter) of two text file. If this 10 rows are equal I need to create two new text files equal to the previous ones but without the first 10 rows compared, otherwise I would like to print the files are not the same. This is my script, but it doesn't work. The error is get-content was unexpected at this time. Can you help me? Thanks

*@echo off
setlocal enabledelayedexpansion
if (Compare-object (get-content C:\Users\file1.txt | select -First %n%) (get-content C:\Users\file2.txt | select -First %n%))
{echo "not equal"}
else
{
get-content C:\Users\file1.txt | select -Skip 10 > C:\Users\file1_clear.txt
get-content C:\Users\file2.txt | select -Skip 10 > C:\Users\file2_clear.txt
}*

Aucun commentaire:

Enregistrer un commentaire