April 13, 2018 at 9:04 am
Hello,
i thought i had a simple powershell script, its just suppose to check if folder exists, if it doesnt, create it using the name as a date.
however i get the following error:
A job step received an error at line 9 in a PowerShell script. The corresponding line is 'new-item -ItemType Directory -Path $path -Force '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Invalid Path: '\\Lucy\ShareVol\FDB\Archived\04122018'. '. Process Exit Code -1. The step failed.
I run the powershell script manually and it works great, however i run it on SQL Agent... and it fails giving the above error message 🙁
$datetime = Get-Date -uformat "%m%d%Y"$path = "\\Lucy\ShareVol\FDB\Archived\"+$datetime#$path = "\\Lucy\ShareVol\FDB\Archived\"+[datetime]::Today.ToString('MM')+[datetime]::Today.ToString('dd')+[datetime]::Today.ToString('yyyy')If(!(test-path $path)){new-item -ItemType Directory -Path $path -Force}
also same problem for step 2, works fine if i run manually, but run it in SQL agent... it doesnt work:
#$datetime = Get-Date -uformat "%m%d%Y"#$Dest = "\\jupiter\production\FDB\Archived\"+$datetimeMove-Item -Path "\\jupiter\production\FDB\FilesToProcess\*" -Destination $Dest
please help, any input.
A job step received an error at line 6 in a PowerShell script. The corresponding line is 'Move-Item -Path "\\Lucy\ShareVol\FDB\FilesToProcess\*" -Destination $Dest '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Cannot retrieve the dynamic parameters for the cmdlet. Invalid Path: '\\Lucy\ShareVol\FDB\FilesToProcess'. '. Process Exit Code -1. The step failed.
thanks in advance.
April 13, 2018 at 9:32 am
where are the line breaks? I ran it putting them where I thought they should go and got no errors...
April 13, 2018 at 10:08 am
that could be the problem, can you show me where to put them? i am new to powershell.
thanks 🙂
April 13, 2018 at 11:17 am
I had to change the path:
$datetime = Get-Date -uformat "%m%d%Y"
$path = "c:\temp\"+$datetime
#$path = "\\Lucy\ShareVol\FDB\Archived\"+[datetime]::Today.ToString('MM')+[datetime]::Today.ToString('dd')+[datetime]::Today.ToString('yyyy')
If(!(test-path $path)){
new-item -ItemType Directory -Path $path -Force
}
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply