Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Make unzip scrip run on another machine

$
0
0

H i all so I came up with this little script. It's very unoptimized and I want to make the unzip part into a function. My main question is I'm copying this zip folder to another machine. Will it actually use this machine to unzip or will the work load be done on the host that I'm sending it from.

Here's the code:

$a = Get-Content C:\Users\cody-horton\Desktop\list.txt

function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}

for($i=0;$i -lt $a.Length; $i++){
    if(!(Test-Connection -Cn $a[$i] -BufferSize 16 -Count 1 -ea 0 -quiet)){
        Write-Host $a[$i] -foregroundcolor red

    }
    else{

        #Create directory
        New-Item -ItemType directory -Path "\\$($a[$i])\C`$\Users\Public\Documents\Android SDK\adt-bundle-windows-x86_64-20131030\sdk\" -Force
        #Move zip to directory
        Copy-Item "\\nlcr2553218x4-1\C`$\Users\ttinker\Desktop\adt-bundle-windows-x86_64-20131030.7z" "\\$($a[$i])\C`$\Users\Public\Documents\Android SDK\adt-bundle-windows-x86_64-20131030\sdk" `
        -Recurse -Force

        #Unzip file
        Expand-ZIPFile –File "\\$($a[$i])\C`$\Users\Public\Documents\Android SDK\adt-bundle-windows-x86_64-20131030\sdk\adt-bundle-windows-x86_64-20131030." `–Destination "\\$($a[$i])\c$\Users\Public\Documents\Android SDK\adt-bundle-windows-x86_64-20131030\sdk"
        #Delete zip folder
        Remove-Item "\\$($a[$i])\C`$\Users\Public\Documents\Android SDK\adt-bundle-windows-x86_64-20131030\sdk\adt-bundle-windows-x86_64-20131030.7z" -Recurse

        Write-Host $a[$i] -foregroundcolor green

    }

}

$b = new-object -comobject wscript.shell
$c = $b.popup("DONE!!",10,"Test Message Box",1)
Would I need to make a batch file and if so how would I do this. Thanks


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>