CMD has been around for decades, but PowerShell has become a more efficient tool for managing Microsoft products. These PowerShell cmdlets can knock out tasks you used to handle via the command line.
When Microsoft developed PowerShell (PS) in November 2006, the aim was to marry a command-line based interface and a scripting language to handle task automation and configuration management of native Microsoft applications. Through the years it has seen upgrades that increase its functionality, with more cmdlets (PS commands) and more support through importing modules to grant the framework greater flexibility in managing a variety of services.
As PowerShell's popularity has increased, its adoption rate has fueled further changes. Arguably the largest and most recent of these was Microsoft's decision to make PS open source, porting it to various Linux distributions and macOS and enabling cross-platform support through one unified shell. What does this mean for non-PowerShell users? Simply put, PS is poised to not only replace the venerable command line that Windows admins know—but as organizations grow their user base with Linux and macOS-based devices, admins can port that knowledge over to managing those devices as well, all from one console or shell.
For those who support Windows-only organizations, Microsoft has made inroads toward PS-based management by ensuring that much of its higher-level software, such as Windows Server, Active Directory, and Exchange, will be 100% manageable only through PowerShell. Users managing services through the GUI or admin consoles won't be able to fully configure every aspect of the application unless they switch to PowerShell. So here are some commonly used commands you may find are part of your daily admin tasks—and the PS equivalent—to help you migrate your usage over to PowerShell.
SEE: Windows administrator's PowerShell script kit (Tech Pro Research)
1. Changing directories
PS: Set-Location "path/to/directory"
2. Listing files in a directory
3. Renaming files
PS: Rename-Item "path/to/file.ext" -NewName "newfilename.ext"
4. Getting help for a command
PS: Get-Help "Cmdlet name"
5. Stopping processes
PS: Stop-Process -Name "application.exe"
6. Forcing Group Policy refresh
CMD: gpupdate /force
PS: Invoke-GPUpdate -Computer "Hostname" -Force
7. Shutting down local (or remote) computer(s)
CMD: shutdown -s
PS: Stop-Computer -ComputerName "Hostname1","Hostname2", "localhost"
8. Restarting local (or remote) computer(s)
CMD: shutdown -r
PS: Restart-Computer -ComputerName "Hostname3", "localhost"
9. Setting variables
CMD: SET variable="value"
PS: $"variablename" = "value"
10. Joining a computer to a domain
CMD: netdom /domain:domainname /user:username /password:password member hostname /add
PS: Add-Computer -DomainName "Domain" -Credential "Domain\Username" -Restart
While this list is in no way exhaustive, it's a good first step toward treading PowerShell's relatively deep waters in a way that allows you to get hands-on experience using it. It also provides a good jumping-off point for those who want to navigate further into PS and learn more about how its cmdlets can be be used for greater manageability and to automate daily, repetitive tasks.
- PowerShell: The smart person's guide (TechRepublic)
- 10 PowerShell commands every Windows admin should know (TechRepublic)
- 10 reasons why you should learn to use PowerShell (TechRepublic)
- Microsoft delivers PowerShell core for Windows, Linux, Mac (ZDNet)
- Microsoft open sources PowerShell; brings it to Linux and Mac OS X (ZDnet)
Other tips for transitioning to PS?
What cmdlets have you started using to simplify command-line tasks? Share your advice with fellow TechRepublic members.