Goatee PFE

Blog of Microsoft Premier Field Engineer Ashley McGlone featuring PowerShell scripts for Active Directory.

Free Download: CMD to PowerShell Guide for AD

Free Download: CMD to PowerShell Guide for AD

  • Comments 17
  • Likes

New Years ResolutionSkip the treadmill.  Learn PowerShell.

Hi folks. It's your friendly, neighborhood PFE again. In order to avoid the long lines to buy a treadmill the first week of January I thought I would save you some time and give you an easier New Years Resolution… Learn PowerShell.

It's time to part with "blankie".

For years many of us have relied on trusty command line utilities like PING, IPCONFIG, and REPADMIN. Some of us are still hanging on to those instead of embracing the brave new world of PowerShell.

In an effort to assist with the transition and to introduce some of the cool new cmdlets in PowerShell v3 I have created a free reference guide showing how the old meets the new. For example, instead of PING try the PowerShell cmdlet Test-Connection, instead of NSLOOKUP use Resolve-DNSName, instead of GPUPDATE use Invoke-GPUpdate.

The guide attached at the bottom of this blog post contains four packed pages of PowerShell pleasure for your perusing.

Why?

Why would someone want to use PowerShell instead of command line utilities? There are several reasons:

  1. Command line utilities often give us the data we want, but it is flat text that requires parsing to do anything else with it. Have you ever scripted a command line PING and tried to find the result? Yeah, I have, and it's a pain. Now with PowerShell you can simply reference the ping result properties coming back to easily get the actual data involved.
  2. Is your favorite command line utility always available? When you would RDP to a server back in the day you had no idea if the adminpak.msi or the Windows Resource Kit was installed. Now you know that PowerShell is always there on Windows Server 2008 R2 and above.
  3. PowerShell cmdlets mostly use the same syntax. You no longer have to figure out what the right switch is for the remote computer name. Now it is always "-ComputerName".
  4. PowerShell is not just the future, it's now. Version 1 was released five years ago. Now all of the Microsoft server products use PowerShell. Windows 8 and Server 2012 now have thousands of cmdlets at your finger tips.

Free Download

While studying the new 2012 cmdlets in preparation for conference talks last summer I created a quick cheat sheet for PowerShell equivalence to REPADMIN and DNSCMD. The other day I sat down and expanded this to include a raft of familiar utilities:

REPADMIN
DCPROMO
CSVDE
NETDOM
NLTEST
GPUPDATE
GPRESULT

DSGET
DSQUERY
DSADD
DSMOD
DSRM
DSMOVE
DSACLS

DNSCMD
NSLOOKUP
PING
IPCONFIG
NETSTAT

This guide will get you off and running to convert any old batch files you still have lying around or hiding in scheduled tasks.

Four pages. Really?

Yes. I know that sounds like a lot to learn, but the good news is I can't remember them all either. I work for Microsoft, and I still use Show-Command, Get-Command, and Get-Help on a daily basis. That's why we put those cmdlets in the box. With over 2,400 cmdlets now there's a good chance we've got you covered for anything you need. If not, let us know on the Connect site.

There are so many command line utilities out there that I had to limit my focus to those related to Active Directory. Hopefully this post will inspire others in the community to compile similar guides for their technologies.

Disclaimer

I created this guide based on my personal knowledge of the tools and the help text that they print. In other words this is not a top secret guide published by Microsoft product groups, and I have not tested every single entry. Some of these will require you to use Get-Help to explore the capabilities. I built this by hand in Excel, so you may be able to find some gaps in the list. If you find any omissions or corrections please send them my way, and I'll update the document.

Enjoy. Happy New Year!

 

photo credit: eccampbell via photopin cc

Attachment: PowerShell Cmd Line Conversion Guide AD.pdf

Can you help me?  Yes!

If you would like to have me or another Microsoft PFE visit your company and assist with the ideas presented in this blog post, then contact your Microsoft Premier Technical Account Manager (TAM) for booking information.

For more information about becoming a Microsoft Premier customer email PremSale@microsoft.com.  Tell them GoateePFE sent you.

Sharing Links
Comments
  • This is great Ashley, already printed it out and tweeted.   You are definitely the number one guy when it comes to AD and powershell.  Happy New Year!

    Thanks

    Mike

  • Do you know if the version 3 AD cmdlets are available in a 2008R2 domain if you load the AD Powershell module from a Windows 8 workstation with RSAT installed?

  • Hello LA,

    That is correct.  The RSAT installed determines the level of functionality for the AD Module.  With the Windows 8 RSAT you can target any DC running the AD web service (2003, 2008, 2008 R2, 2012) to use all of the latest cmdlets.  Obviously 2003 and 2008 would need the ADMGS install (http://aka.ms/ADPS2003).  Conversely the Windows 7 RSAT can access 2012 DCs using the older cmdlets only.

    Ashley

  • this is cool, thanks

  • Excellent :)

    Thanks

  • Awesome sheet, i bet people at Ask Directory Services Team blog would be glad to share the word !

  • I do see ping but missing tracert or am I still blurry from NYE.

  • Ashley,

    Thanks for the PowerShell Guide.  I'm going to review it now and hope to draw some things to share with my team.

  • Awesome thanks Ashley =)

  • Well done Ashley! This is just the sort of thing that has been missing for a long time. Thanks for doing the work and producing this excellent documentation!

  • Wonderful Resource!

  • I was about to send this to Mike when I saw his comment.

  • Ashley, THANK YOU VERY MUCH for this wonderful document. I observed that DCDIAG is not covered in this document. Hope you add it in next version of this document. Thanks again.

  • Someone asked if there are any updates for Windows Server 2012 R2. Run this on 2012 R2: "PS> Get-Command *AuthenticationPolicy*" These are the only new AD cmdlets. These are for a new feature and have no CMD equivalence to update on the sheet.

  • Thank you very much!

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment