Powershell help!

wsousa1wsousa1 Member Posts: 8 ■□□□□□□□□□
Hello All,

i have written a script that is used to automate application web releases. this script will copy new releases to a temp folder in our prod environment, qc it , if it passes then proceed with a backup of production, qc again then finally deploy the code to production. everything works fine, but every now and then some random web file is locked by another process.

Sample error:
The process cannot access the file 'filenamehere.aspx' because it is being used by another process.
At C:\***** ******.ps1:8 char:1
+ Invoke-Command -computername computername -Creden ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Login.aspx:FileInfo) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
+ PSComputerName : computername

Is there a way to have powershell catch the error and retry to copy the file? Not too long ago when we manually copied and pasted the release code, an error would come up stating that a file was in use, so we would hit retry until it worked. Not sure if the same can be done.

Any help would be greatly appreciated.

Thanks!

Comments

Sign In or Register to comment.