I am trying to extract a zip file to then be downloaded by remote people. Once extracted I will have a script that installs the package but I need to use a compressed folder and the remote users don't have 7zip or anything like it.
I have this but I keep getting an error -
$shell = new-object -com shell.application
$zip = $shell.NameSpace(“C:\name.zip”)
foreach($item in $zip.items())
{
$shell.Namespace(“C:\temp\name”).copyhere($item)
}
The error I am getting is below -
You cannot call a method on a null-valued expression.
At line:5 char:43
+ $shell.Namespace(“C:\name”).copyhere <<<< ($item)
+ CategoryInfo : InvalidOperation: (copyhere:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
There are other issues with the code but this is a work in progress, I will fix the hard coding of values once I can get it to extract.
Does your extract path exist (“C:\\temp\\name”)? To be clear, both of the items in that path should be directories.
That should be a path that already exists. If it doesn't you get that error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.