First, we need to keep our credential information so that we do not have to enter it every time we connect to the remote machine.
$cred = Get-Credential
Then, let us check if remote desktop is enabled. This will tell us if we need to enable it.PS C:\temp> Invoke-Command -computername dev-pc -scriptblock {(gwmi -class win32_terminalservicesetting -namespace "root\cimv2\terminalservices").allowtsconnections} -Credential $cred
If we need to enable it, run the following command.PS C:\temp> Invoke-Command -computername dev-pc -scriptblock {(gwmi -class win32_terminalservicesetting -namespace "root\cimv2\terminalservices").setallowtsconnections(1)} -Credential $cred
Then, run the following one to make sure that authentication is required for remote desktop access.PS C:\temp> invoke-command -computername dev-pc -scriptblock {(gwmi -class win32_tsgeneralsetting -namespace "root\cimv2\terminalservices").setuserauthenticationrequired(1)} -Credential $cred
The above step basically enables Remote Desktop on my dev-pc but the trouble I had was that I still could not connect to my dev box because of firewall so we need to take care of that as well.
To do that, we will need to run one more command.PS C:\temp> invoke-command -computername dev-pc -scriptblock {netsh advfirewall firewall set rule group="remote desktop" new enable=Yes } -Credential $cred
Once we execute the last command, we are now able to remote desktop to remote computer.Lastly, let me put two websites that I got the above scripts from to enable remote desktop.
A couple of posts back I mentioned that I was working on a configuration library for Server 2008 R2 Core and Hyper-V Server R2 and this includes checking and setting the configuration for remote desktop.
ReplyDeleteremote desktop software
I have also worked on to create some script for this have a look : http://aikitsupport.com/checking-and-enabling-remote-desktop-with-powershell/
DeleteI enjoy the them here. Can it be downloadable anywhere?
ReplyDeleteThanks!
Here is my web-site danon jewellery england
Aωesome artісle.
ReplyDeleteΑlѕo νisіt my ωeb ѕite :
: hotmail sign up
Useful information. Fortunate me I found your website by chance, and I'm stunned why this coincidence didn't came about earlier!
ReplyDeleteI bookmarked it.
my web site; xerox 8560mfp driver
Sometimes the easiest means to deleted installed control series is to copy and paste the afflicted section to notepad, tidy up the text you desire
ReplyDeleteprotected, then copy and insert it back.
Here is my blog ... vintagefordfacts.blogspot.com
I truly adored this great guide. Please continue this outstanding operate.
ReplyDeleteMy blog post xerox phaser 8560 toner
It's fantastic that you are getting ideas from this post as well as from our dialogue made at this place.
ReplyDeleteAlso visit my web blog - hultquist jewellery uk
This comment has been removed by a blog administrator.
ReplyDeleteI gotta favorite this website it seems very helpful .
ReplyDeleteTitanium Pendants UK