Have you ever been working on an issue, rebooted the computer, and forgot to remote back in to finish the problem? Wouldn’t it be nice if your computer just magically reminded you?

But why stop at a little reminder, why not have your computer automatically launch a remote session to that computer! PowerShell can do all of this and when embedded in Active Directory Users and Computers, you get instant access to it. Don’t let the length of this script discourage you; setting this process up won’t take more than 10 minutes!

Choose Your Remote Tool

So you made it, great! To enable automatic connections to a client, you will need a remote tool that supports command line options. In our environment, we use a product called NetSupport which works pretty well for this. You should also be able to use Remote Assistance, Remote Desktop, or Concurrent Remote Desktop.

In your saved script, search for this line: &‘C:\Program Files (x86)\NetSupport\NetSupport Manager\PCICTLUI.EXE’ /C”$Computer” /vw /e . Replace the program path (‘C:\….\PCICTLUI.EXE’) with your remote support tool. After the last ‘ mark, add in any silent connection options that you need. Be sure to specify $Computer as the client name/connection name.

If you are using Remote Desktop or Remote Assistance, you can use the commands below:

Remote Desktop: mstsc /V:$Computer

Remote Assistance: msra.exe /offerra $Computer

Adding the Script to Active Directory

The easiest way to access this script is to embed it within your Active Directory Users and Computers MMC. We’ve covered adding scripts to your ADUC MMC a few times. If you have a custom ADUC MMC, create a new task in your Taskpad. If you aren’t using a custom ADUC MMC yet, here are the short steps to creating one.

You should now be at the New Task Wizard. Press Next and select Shell Command. Below is the information that you will need for this task. Be sure to include all quote marks.

Command: c:\windows\System32\WindowsPowerShell\v1.0\powershell.exe

Parameters: -command “”&” ‘”\\SERVER\SHARE\restart-monitor.ps1′””

Continue through the wizard by naming your task and selection an icon. When you want to reboot a machine and automatically reconnect to it, select your new task and type in your computer name. The computer will reboot and your remote control agent will launch when the machine is active again!

& : The term ‘amp’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\AppV_Client_Remote\restart-monitor.ps1:48 char:6
+ & ‘C:\mstsc /V:$Computer’
+ ~~~
+ CategoryInfo : ObjectNotFound: (amp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

& : The term ‘amp’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\AppV_Client_Remote\restart-monitor.ps1:50 char:6
+ & ‘mstsc /V:$Computer’
+ ~~~
+ CategoryInfo : ObjectNotFound: (amp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException