Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This works perfectly
- $src = "C:\temp\test"
- $dst = "C:\temp\test.zip"
- [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
- [System.IO.Compression.ZipFile]::CreateFromDirectory($src,$dst)
- # This fails with: 'Exception calling "CreateFromDirectory" with "2" argument(s): "Could not find a part of the path 'S:\test.zip'."
- $user = "[username]"
- $pass = ConvertTo-SecureString "[password]" -AsPlainText -Force
- $creds = New-Object System.Management.Automation.PSCredential ($user, $pass)
- $psDrive = New-PSDrive -Name "S" -PSProvider FileSystem -Root $sourcePath -Credential $creds
- $src = "S:\temp\test"
- $dst = "S:\temp\test.zip"
- [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
- [System.IO.Compression.ZipFile]::CreateFromDirectory($src,$dst)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement