Можно ли использовать Compress-Archive с использованием PSDrive в -Path и -DestinationPath? - PullRequest
0 голосов
/ 20 апреля 2020

Я использую PSDrive для Compress-Archive, но я сталкиваюсь с этой ошибкой:

Compress-Archive : The path 'Z:\' either does not exist or is not a valid file system path.
At C:\Users\user\somefolder\script.ps1:34 char:5
+     Compress-Archive -Path ($ZDrive + $fileName + $csvExt) -Destinati ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Z:\:String) [Compress-Archive], InvalidOperationException
    + FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive

Код PSDrive и коды в строках 33 и 34:

New-PSDrive -Name "Z" -Root $OutputDirectoryPath -PSProvider FileSystem;
$ZDrive = "Z:\";
query($CustomQuery) | Export-Csv -Path ($ZDrive + $fileName + $csvExt) -NoTypeInformation;
Compress-Archive -Path ($ZDrive + $fileName + $csvExt) -DestinationPath ($ZDrive + $fileName + $zipExt) -Force;
...