remote desktop starts
$session = new-pssession -computername 192.168.0.24 -credential $credential
#download notepad++ on remote desktop
PS C:\Windows\System32> invoke-command -session $session -scriptblock {
>> $url = "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v7.8.8/npp.7.8.8.Installer.x64.exe"
>> $outFile = 'C:\Users\public\Desktop\npp.7.8.8.Installer.x64.exe'
>> [System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls12
>> Invoke-WebRequest -Uri $url -Method Get -OutFile $outFile
>> }
#verify program downlaoded
PS C:\Windows\System32> $downloadComplete = invoke-command -session $session -scriptblock {
>> $outFile = 'C:\Users\public\Desktop\npp.7.8.8.Installer.x64.exe'
>> Test-Path $outFile
>> }
PS C:\Windows\System32> $downloadComplete
True
notepad++ downloaded
#install notepad in the background
PS C:\Windows\System32> invoke-command -session $session -scriptblock { >> $outFile = 'C:\Users\public\Desktop\npp.7.8.8.Installer.x64.exe' >> Start-Process -Wait -FilePath $outFile -ArgumentList "/S" -PassThru >> }
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName PSComputerName ------ ----- ----- ------ -- -- ----------- -------------- 8 1.44 3.70 0.28 1460 0 npp.7.8.8.Installer.x64 192.168.0.24
notepad++ intstalled on remote computer
reference:
SSL/TLS secutiry
silently install program
No comments:
Post a Comment