Archive for category PowerShell
Save Password in .RDP File
Posted by Nerd in Microsoft, PowerShell, Scripts on January 23, 2009
I shared with you how to create multiple .rdp files with Powershell, and now, I want to show you how to make your job even easier! I ran across this blog, and downloaded his RDP password Hash program. It got me thinking, I could make my job easier by saving the password in a hashed format in each RDP file that my Powershell script creates!
** Note: Please see my original post about this if you have questions of the files needed, and folder structure.
First, I modified the .CSV file, adding a new column “PASS” – in that column, add the hashed password created from remkoweijnen.nl’s password hash program [DOWNLOAD]
Then I modified my Powershell script, adding in the password to script, so it’s added to the .RDP file.
No more typing in passwords to connect to servers. Also, the nice thing is, if you have to change the password, just modify the hash file in the .CSV file, and re-run the Powershell script!
Here is the modified Powershell Script:
$List = Import-CSV RDPLIST.CSV $resolutions = ("Console","Cullscreen","Widescreen","Docked") ForEach($Entry in $List) { ForEach($resolution in $resolutions) { # Prepend the destination directory info for RDP files $Dir = "..\" + $resolution + "\" + $Entry.Directory # Create new folder New-Item -Path $Dir -ItemType Directory -Force # Build the file name $FileName = $Dir + "\" + $Entry.ServerName + ".RDP" # Remove the old file Remove-Item $FileName -Force # Begin building RDP file $temp = "`nfull address:s:" + $Entry.IP switch ($resolution) { "Console" { $temp += "`nscreen mode id:i:1" $temp += "`ndesktopwidth:i:1024" $temp += "`ndesktopheight:i:768" $temp += "`nusername:s:" + $Entry.USER $temp += "`npassword 51:b:" + $Entry.PASS $temp += "`nadministrative session:i:1" } "Fullscreen" { $temp += "`nscreen mode id:i:2" $temp += "`nusername:s:" + $Entry.USER $temp += "`npassword 51:b:" + $Entry.PASS } "Widescreen" { $temp += "`nscreen mode id:i:1" $temp += "`ndesktopwidth:i:1152" $temp += "`ndesktopheight:i:720" $temp += "`nusername:s:" + $Entry.USER $temp += "`npassword 51:b:" + $Entry.PASS } "Docked" { $temp += "`nscreen mode id:i:1" $temp += "`ndesktopwidth:i:1152" $temp += "`ndesktopheight:i:864" $temp += "`nusername:s:" + $Entry.USER $temp += "`npassword 51:b:" + $Entry.PASS } } $temp | out-file $FileName write-host $temp get-content template_bottom.txt >> $FileName } }
Create multiple RDP files with Powershell
Posted by Nerd in Microsoft, PowerShell, Scripts on September 13, 2008

RDP – Remote Desktop Connection, or what we called back in the day, Terminal Services. Every system administrator uses it daily. At work, the team I work on has 145 servers that we are responsible for, and only a handful of them are in the same building as us (although we still remote into them as well).
This being said, I was getting tired of typing in the server’s name or IP address every time I needed to connect to it. I know Microsoft has an mmc for Remote Desktops, but I just don’t like the clunky way it has to be setup, plus, did I mention I had 145 to put in? Well, call me lazy, but I knew there had to be a way to script it – after all, a RDP file is nothing but some text (open a .rdp file with notepad – you’ll see!).
So, enough background, lets do some scripting! There are 3 files here: Powershell script, a CSV file, and a Text file.
- First, the CSV File: It has 4 columns with the first row being the headers. Do not change row. Name this file RDPLIST.csv
- Next, is the Text File. This contains other parameters that are going to be the same between every connection – such as enabling shared clipboard, 16bit colors, disable themes, etc. You can customize this to your liking (to get it just the way you want it, create an .rdp file, and edit it with notepad, and you will see a list similar to below). Name this file template_bottom.txt
- Lastly, the Powershell script: Name this file CreateRDP.ps1
ServerName,IP,Directory,USER FRIENDLYNAME,FQDNorIP,FOLDERNAME\SUBFOLDER,DOMAIN\USERNAME
audiomode:i:2
authentication level:i:0
autoreconnection enabled:i:1
bitmapcachepersistenable:i:1
compression:i:1
disable cursor setting:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
disable wallpaper:i:1
displayconnectionbar:i:1
keyboardhook:i:2
redirectclipboard:i:1
redirectcomports:i:0
redirectdrives:i:0
redirectprinters:i:0
redirectsmartcards:i:0
session bpp:i:16
prompt for credentials:i:0
promptcredentialonce:i:1
$List = Import-CSV RDPLIST.CSV $resolutions = ("Console","fullscreen","1024x768","1152x864") ForEach($Entry in $List) { ForEach($resolution in $resolutions) { # Prepend the destination directory info for RDP files $Dir = "..\" + $resolution + "\" + $Entry.Directory # Create new folder New-Item -Path $Dir -ItemType Directory -Force # Build the file name $FileName = $Dir + "\" + $Entry.ServerName + ".RDP" # Remove the old file Remove-Item $FileName -Force # Begin building RDP file $temp = "`nfull address:s:" + $Entry.IP switch ($resolution) { "Console" { $temp = $temp + "`nscreen mode id:i:1" $temp = $temp + "`ndesktopwidth:i:1024" $temp = $temp + "`ndesktopheight:i:768" $temp = $temp + "`nusername:s:" + $Entry.USER $temp = $temp + "`nadministrative session:i:1" } "Fullscreen" { $temp = $temp + "`nscreen mode id:i:2" $temp = $temp + "`nusername:s:" + $Entry.USER } "1024x768" { $temp = $temp + "`nscreen mode id:i:1" $temp = $temp + "`ndesktopwidth:i:1024" $temp = $temp + "`ndesktopheight:i:768" $temp = $temp + "`nusername:s:" + $Entry.USER } "1152x864" { $temp = $temp + "`nscreen mode id:i:1" $temp = $temp + "`ndesktopwidth:i:1152" $temp = $temp + "`ndesktopheight:i:864" $temp = $temp + "`nusername:s:" + $Entry.USER } } $temp | out-file $FileName write-host $temp get-content template_bottom.txt >> $FileName } }
Now, you need a folder structure:
- Powershell_RDP
- rdp
- _script

Put all three files in the _script folder.
- rdp
And just because I’m a nice guy, here’s a zip of the files and the correct folder structure. Just unzip, make your edits to the csv file, save and close it, and open PowerShell (as Administrator if using Vista) and navigate to the _Script folder. Once there, run the CreateRDP.ps1 (put a ./ in front of the filename)
Feel free to customize this script to your own liking! It’s a simple script, so it shouldn’t be too hard to mess with. It works like a CHARM!!! I created 290 RDP files in less than 30 seconds! Great thing is, it creates a separate folder structure for the different resolutions (I used 1024×768 & 1152×864 because my laptop is a widescreen, but when I’m docked, it’s a standard monitor).
One more tip, I made two new toolbars, and pushed them all the way over to the right of the taskbar, making a nifty little launcher!

Hope you enjoy this – I know I did! It took me longer to write this post than it did to get all my .RDP files!
[ UPDATE: Original Script was written by Aaron Dodd, just tweaked by me]
Free E-Book: PowerShell
Posted by Nerd in Free, PowerShell, Tip, Training on June 15, 2007
Source: https://blogs.technet.com/chitpro-de
English version of Windows PowerShell course book available for download
Due to its great popularity, we have decided to translate the Windows PowerShell course book to English. The book gives you a short introduction with many exercises about the interactive part of Windows PowerShell as well as some hints how to use other objects like WMI, .NET or COM objects like Excel or Internet Explorer.
The book is available for free and you can share it with all your colleagues or friends if you leave it as it is. The books can be used with or without the demo files available at this blog as well.

DPM Style
Exchange Style
Nerd with a .45