I am new to PowerShell and am trying to create a small program to backup five database files on an hourly basis to a local drive. (This is not the only backup solution being used.) I am employing the write-zip cmdlet to do this and encounter
errors if one of the databases is being used. Using the command
write-zip -path $sourcepath -outputpath $targetpath -level 1
I get a message that:
"The process cannot access the file X.mdb because it is being used by another process."
This is not an issue if I first copy the files to a temp directory, zip the files and then delete, as follows:
copy-item $sourcepath $temppath
write-zip -path $temppath -outputpath $targetpath -level 1
Although that will work easily because there are only five files being copies, it seems rather inefficient. Is there some way to force the copy/zip of the file using the write-zip cmdlet? I have tried including a -force in the line but it is
not a recognized parameter. Any help would be appreciated. Thanks.