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

Help with PSexec command

$
0
0

Hi everyone so I have this script that pulls a file from another machine and then unzips it.

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)
}
}

       #Create directory
        New-Item -ItemType directory -Path "C:\Users\Public\Desktop\Android sdk" -Force
        #Move zip to directory
        Copy-Item "\\tsvc2552142x011\C`$\Users\cody-horton\Desktop\adt.7z" "C:\Users\Public\Desktop\Android sdk" `
        -Recurse -Force

        #Unzip file
        Expand-ZIPFile –File "C:\Users\Public\Desktop\Android sdk\adt.7z" `–Destination "C:\Users\Public\Desktop\Android sdk"
        #Delete zip folder
        Remove-Item "C:\Users\Public\Desktop\Android sdk\adt.7z" -Recurse

So it works but I'm having trouble using the PSexec command. I can successfully open up the computers command prompt by using psexec  "computer name" cmd. Then if I try to run my script it doesn't work. 

I'm not sure what I'm doing wrong or if there was a better way to do this. Thanks any help is appreciated.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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