我使用PowerShell解压缩文件。它起作用了,但现在不行了。我不知道为什么,这是相同的代码。
$path = "C:\tmp\test.zip"
$date= Get-Date -DisplayHint Date -Format yyMMdd
$destination = "I:\"+$date+"\zk\"
$shell_app= New-Object -com shell.application
$files = Get-ChildItem -Path $path -filter *.zip -recurse
foreach($file in $files) {
$zip_file = $shell_app.namespace($file.FullName)
$copyHere = $shell_app.namespace($destination)
$copyHere.Copyhere($zip_file.items())
}
错误讯息:
You cannot call a method on a null-valued expression.
At line:16 char:3
+ $copyHere.Copyhere($zip_file.items())
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull