Alright so this isn't related to vmware or powercli, but I have all my scripts output to a temp folder then ftp them to a webserver. I then have a script run daily to delete any temp file that is older than 60 Days, well just realized sometime ago the script has been failing. This is the script:
Get-ChildItem "C:\util\scripts\Temp" -Recurse | where {$_.LastWriteTime -lt (Get-Date).AddDays(-60)} | Remove-Item
And I have a scheduled task run daily with the highest privileges and a local admin creds. I am now getting a 0x103 error saying its taking to long before I have the task scheduler term the attempt.
Any ideas?
A couple of things:
$d = (Get-Date).AddDays(-60)
Get-ChildItem -Path C:\Temp | where{$_.Name -match ".csv$|.htm$" -and $_.LastWriteTime -lt $d} | Remove-Item -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I don't have the answer, but have you ran the script at the PowerShell prompt, without running it through task scheduler? Maybe the account that it runs under has an issue, or maybe some other scripts are running causing that one to hang.
I moved the time that it runs but still no change.
Do you actually need the Recurse switch on the Get-ChildItem?
Are these reports organised in subfolders under C:\util\scripts\Temp?
Do these reports have similar file types (.csv, .html...)?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There are no subfolders but there are both .csv and .htm files.
A couple of things:
$d = (Get-Date).AddDays(-60)
Get-ChildItem -Path C:\Temp | where{$_.Name -match ".csv$|.htm$" -and $_.LastWriteTime -lt $d} | Remove-Item -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference