Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Checking that a file backed up to the NAS exists

$
0
0

I have a backup powershell script that copies files from the server to our NAS, which is remotely located with a login.  I am writing a powershell script to check that the file has been backed up, but I'm having trouble doing this with the credential part, since Test-Path credential option doesn't work, and invoke-command doesn't work without remote desktop, which the NAS doesn't have.  

I was thinking of trying to use the New-PSDrive command somehow to check it, since that's what I used to get source and destination setup for the File-Copy, but I'm not familiar enough with the commands to figure out how to accomplish this.

This is how I did the copy:

      New-PSDrive -Name source -PSProvider FileSystem -Root "$SourcePath" | Out-Null

      New-PSDrive -Name target -PSProvider FileSystem -Credential $cred -Root "$DestPath" | Out-Null

      Copy-Item -Path source:\$filename -Destination target:\VMs\$newDestFileOnly

      Remove-PSDrive source

      Remove-PSDrive target

 

Would I be able to do a Test-Path target:\VMs\$newDestFileOnly    ?  I've been trying to figure this out for a long time and haven't found any info online that was similar enough.  So far I saw: http://stackoverflow.com/questions/21335134/how-to-test-writing-to-a-file-share-path-using-credential

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles