Positional Parameter cannot be found

I have a script and it gives me this error. Positional parameter cannot be found. Please can someone help me.

ASAP

 #Check the logifle to be smaller than 10MB, otherwise do a rollover
get-item C:\Temp\outputtest.txt | ForEach-Object { 
if ($_.lenght -ge 10MB) {
(get-date).ToString() + "  " + "Performing a logfile rollover" | out-file -filepath 'C:\Temp\outputtest.txt' -Append
move-item -Path C:\Temp\outputtest.txt -DestinationC:\Temp\outputtest.txt -Force
(get-date).ToString() + "  " + "Logfile rollover completed succesfully" | out-file -filepath 'C:\Temp\outputtest.txt' 
}
}
September 1st, 2015 6:03am

Hi Nafeesa,

you messed up the Move-Item parameter "-Destination". Leave a space after that. Then fix some typos ... oh well, here ya go:

#Check the logifle to be smaller than 10MB, otherwise do a rollover
get-item C:\Temp\outputtest.txt | ForEach-Object {
	if ($_.length -ge 10MB)
	{
		"$((get-date).ToString()) Performing a logfile rollover" | out-file -filepath 'C:\Temp\outputtest.txt' -Append
		move-item -Path C:\Temp\outputtest.txt -Destination "C:\Temp\outputtest.txt" -Force
		"$((get-date).ToString()) Logfile rollover completed succesfully" | out-file -filepath 'C:\Temp\outputtest.txt' -Append
	}
}

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 6:15am

Hi,

The script is working now and the reason was that the path had space and it was not in quotes.

SORRY I DID NOT PUT THE CORRECT PATH HERE. It was C:\Program Files..... So the space between the 'Program Files' was causing the problem. And now I have put this path in qoutes so it is working. :)

Thanks Fred

September 1st, 2015 11:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics