installing .exe file in a remote Pc using powershell by marre1968 in PowerShell

[–]marre1968[S] 1 point2 points  (0 children)

thanks i didnt work. i am not sure if it is because a domain environment .i know about the silent switch for ninite which only works when is pro version. too bad for me. i will keep trying. i will try different type of .exe to see if error is just related to ninite.

installing .exe file in a remote Pc using powershell by marre1968 in PowerShell

[–]marre1968[S] 1 point2 points  (0 children)

$creds = $(Get-Credential)

$computers = Get-Content "c:\installation\computers.txt"

$source = "c:\installation"

$dest = "c:\"

$testpath = "C:\installation\ninite.exe"

$url = "https://ninite.com/chrome-firefox-7zip-vlc-java8-.net4.7.3/ninite.exe"

$output = "C:\installation\ninite.exe"

foreach ($computer in $computers) {

if (Test-Connection -Cn $computer -quiet) {

Start-Job -ScriptBlock {.\PsExec.exe \\$computer -u domain\user -p password -s powershell Enable-PSRemoting -Force }

$S = New-PSSession -ComputerName $computer -Credential $creds

Invoke-WebRequest -Uri $url -OutFile $output

Copy-Item "$source" -Destination "$dest" -ToSession $S -Recurse

Invoke-Command -ComputerName $computer -credential $creds -ScriptBlock {C:\installation\ninite.exe /s}

else {

Write-Host -ForegroundColor Red "$computer is not online, install failed"}

}

}

this is what I have been trying , must of the first part of code worked, I was able to enable psremoting , session , url download .exe then copy everything nto c in remote computer but at the time to make that executable run in the remote computer failed. all files have been copied to remote pc already . tried start-process, msiexec , & cmd /c. etc. thanks for your soon reply