Archive

Posts Tagged ‘powershell’

How to use PowerShell and PsExec to change the RDS license server name on all your XenApp servers

March 7th, 2013 No comments

Let’s say you decide to decommission your Remote Desktop Services (RDS)/Terminal Services Licensing Server or you moved your TS/RDS CALs to a different server. That means you need to change the name to the new server under Remote Desktop Session Host Configuration on all your XenApp servers.

1

This is a pain to do manually when you have several hundred XenApp servers. You can do it through group policy but you may only want to change it on a subset of servers in an OU and not all of them. So I used PowerShell and PsExec to precisely target all my XenApp servers I wanted to change. It’s a very quick option when you are pressed for time.

You’ll need to create rds.bat and rds.ps1 and put them in "d:\rdsscript" on the server you plan to run the Powershell script from. You’ll want to share out your "d:\rdsscript" folder on the server you plan on running the script from, otherwise you might get Access Denied errors because the script references a UNC path. The contents of these two files is below.

rds.bat contents:


powershell.exe -executionPolicy unrestricted -command 
"\\yourserver\rdsscript\rds.ps1"

rds.ps1 contents:


Import-Module RemoteDesktopServices
cd RDS:\
cd .\RDSConfiguration\LicensingSettings\SpecifiedLicenseServers
new-item –name newlicenseserver.yourdomain.fqdn
remove-item oldlicenseserver.yourdomain.fqdn -confirm:$false -recurse:$true

Modify the rds.ps1 script with the name(s) of the servers you want to add a the name(s) of the servers you want to remove. You can run rds.bat locally on a XenApp server as a test to see if it worked.

Now it’s time to run it on all your XenApp servers remotely. You can use any number of delivery methods. Again I chose to use PsExec because it’s quick and gets the job done. I highly recommend doing your dev, staging, etc. servers first before doing it in production.

Now copy PsExec.exe into the "d:\rdsscript" folder. You’ll also want to create psexec.bat and xenappserverlist.txt now. Here are the contents of the two files:

psexec.bat contents:

psexec -s @xenappserverlist.txt "\\yourserver\rdsscript\rds.bat" 
pause

xenappserverlist.txt contents:


XenAppServer01
XenAppServer02
XenAppServer03
XenAppServer04
XenAppServer05

So your shared directory on the server you plan on running the script from will look something like this:

2

Now just double click on psexec.bat and it will run the script on each of your XenApp servers in the list. The “-s” tells psexec to execute as the local system account so you don’t have to put your username and password in the script. I don’t like to put usernames and passwords in the script because doing that would send it across the network in plain text so it may be a security concern.

Hope this helps. Let me know if you have any other methods to accomplish an RDS license server migration quickly. I’m always looking for more options. :)

What’s new and actually useful in Server 2008 R2?

November 13th, 2009 No comments

newefficiency

I was lucky enough to attend the Microsoft New Efficiency event for Windows Server 2008 R2 on Monday.  It was a limited capacity technical briefing aimed at IT Professionals.  They also had an Exchange 2010 and Windows 7 track at the same time but I chose to attend the Server 2008 R2 track.  It was divided into 4 sections and was hosted by Kevin Saye (kevin.saye@microsoft.com) who is the Pre-sales technical support specialist for Windows Server in this region.  I’ve heard him speak at events before but never had a chance to actually do a QA session with him till now.

So, on to the new stuff in Server 2008 R2 that I found interesting!  This is not a comprehensive list by an means, just the stuff I thought was very useful.  I’ll go over each in detail in the coming days and how it will fit into your enterprise environment.

-Active Directory Administrative Center (ADAC)
-Managed Service accounts
-Active Directory Recycle Bin
-Graphical PowerShell
-Turning off CPU cores to conserve power
-Group policy can now execute Powershell scritpts
-Group policy granularity through item level targeting
-FCI to classify data and take actions on it
-.NET now runs on Server Core installs
-Remote Desktop Services now has multi-monitor support (up to 8 monitors), bi-directional audio (useful for VOIP), and enhanced multimedia support using your local graphics card instead of “screen painting” as it was before.
-DirectAccess with Windows 7 and Server 2008 R2 – Extends the network to include remote users instead of just a remote user dialing in via VPN.  Uses the Teredo protocol.  Was able to access the Microsoft intranet site (http://msw) without ever having to dial in and from behind a corporate firewall.  It uses IPsec and it only works with Windows 7 machines which are on the domain. 
-Branch Cache – Caches only the requested data unlike DFS.  Means a lot less space is required unlike DFS which is an exact duplicate.

THE FUTURE
Kevin says expect to see more componentization in MS products.  Expect to moved vhds around on servers like OS, Apps, & Data vhds interchangeably on your VMs.

VMware vSphere PowerCLI scripts to make your ESX Admin life easier

November 6th, 2009 2 comments

VMware vSphere PowerCLI is an extremely powerful command line utility you can use to automate every aspect of your ESX environment.  We’re talking every level from VMs, the host OS, storage, networking, licensing, and more!  Basically its a ton of PowerShell cmdlets specifically for ESX that sit on top of Windows PowerShell.

You can download it here if you never played with it before:

http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit?view=overview

They have very good documentation and sample scripts to try out at the link above.  Now the fun part.  What’s the first script you should try out?  My advice is vCheck by Alan Renouf.

PowerCLI vCheck (Daily Report)http://www.virtu-al.net/2009/11/04/vcheck-daily-report-v3/ – Without a doubt one of my favorite PowerCLI scripts.  Every morning when you arrive to the office, you can have an email report waiting in your Outlook Inbox with the status of your entire ESX environment.  Every aspect of it.  From old snapshots to resource utilization on your clusters, it’s all there.  I first started using it at version 1 but version 2 is even slicker!  If you are an ESX admin, you NEED to be using this script!  The lastest version 3 came out the other day and I haven’t used it in a production environment yet but you can download it at the link above.  Al has gone back to calling it vCheck by the way instead of Daily Report.  I’ll be tweaking V3 at home this weekend hopefully if I have the time and test it out.

You can see more scripts from Alan on his blog:

http://www.virtu-al.net/script-list/

I could list them all here with descriptions but he’s done a good job of keeping everything organized in the link above. Try them out!  Let me know if you have any favorite scripts you use.  I’m always looking for new scripts to make life easier so share please. :)