Answer the question
In order to leave comments, you need to log in
Why doesn't RemoteApp connect from under PowerShell?
Good evening!
There is an idea for a script that does the following:
1) Creates a VPN connection
2) Connects via VPN
3) Starts RemoteApp
4) Waits for RemoteApp to complete / close
5) Breaks the VPN connection
6) Deletes the VPN connection.
Here is the script:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Add-VpnConnection -Name VTH_VPN -ServerAddress 1.1.1.1 -AllUserConnection -AuthenticationMethod MSChapv2 -PassThru -RememberCredential -TunnelType Pptp
rasdial VTH_VPN login password
[Console]::outputEncoding =[System.Text.Encoding]::GetEncoding('cp866')
$p = start-process C:\VPN\vth.rdp -PassThru
$p.WaitForExit()
rasdial VTH_VPN /disconnect
Remove-VpnConnection -Name VTH_VPN -AllUserConnection -Force
Answer the question
In order to leave comments, you need to log in
The question is closed. Helped on technet. The solution is as follows (if anyone is interested): in addition to mstsc, the wksprt.exe process (Runtime environment for connections to RemoteApp and remote desktops) is also launched, and it was necessary to check for wksprt.exe, because. apparently mstsc launches it and starts a new process, the final script turns out like this:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Add-VpnConnection -Name VTH_VPN -ServerAddress 1.1.1.1 -AllUserConnection -AuthenticationMethod MSChapv2 -PassThru -RememberCredential -TunnelType Pptp
rasdial VTH_VPN login password
[Console]::outputEncoding =[System.Text.Encoding]::GetEncoding('cp866')
Start-Process mstsc -arg C:\VPN\vth.rdp -NoNewWindow -Wait
while (gps wksprt,mstsc -ea 0) {
Start-Sleep -Sec 1
}
rasdial VTH_VPN /disconnect
Remove-VpnConnection -Name VTH_VPN -AllUserConnection -Force
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question