Often thought of as cmd.exe on steroids, Windows PowerShell is more than just a shell. Despite its name, it actually offers personalized scripting, advanced automation and productivity solutions for administrators and power users. Others are content with the standard command prompt, batch files and perhaps the Task Scheduler that allows basic functionality. With PowerShell much more is possible, as it acts as a bridge between other supporting technologies so users can work easily with .NET, COM, WMI, XML and Active Directory.
Once powershell.exe is launched (update it and install the .NET framework first), you should be ready to create scripts or run standard tests. Keep in mind cmd.exe commands will work within Windows PowerShell, but as admins go beyond simple ping and ipconfig commands, PowerShell proves to be an ideal solution because all their existing knowledge is still valuable. In addition, the language is C#, which is a combo of C+ and Visual Basic that you'll pick up quickly when writing scripts created as a standard text file with the extension .PS1.
Fundamental activities that normally require a third-party application are just as easy within PowerShell. If working on files, for example, you can view the content, search for a pattern or replace text. You can also check the list of files altered by a recent update, manage binary files, determine file encoding type, import and export structured data and much more.
Other common tasks include reusing created code and working with offsite files online or via FTP. But it's in the administrator role that PowerShell is most valuable. Scenarios wherein PowerShell saves time include but are not limited to:
$compareDate = (Get-Date).AddDays(-30)
Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -ge $compareDate }
Pick Your Poison
Scripting, use of cmdlets, workflows and identifying opportunities for automation are at the sysadmin's discretion, as every company or network will have different requirements. The aim is to reduce time and automate common tasks as much as possible. If you'd like to receive daily ping tests from every IP address on your network at 9 a.m., automate it using Windows PowerShell or use the cmd.exe to do it one device at a time. The latter is more tedious. The choice is yours.
Full disclosure? Script creation from scratch isn't even necessary. There are several public online sources available where scripts are ready to download and test before use. Prominent ones include the Microsoft Script Center (which also has a series of webcasts and tutorials) and the PowerShell Code Repository. Some useful scripts within these sources allow you to:
Regardless of the system administration task, it is likely that Windows PowerShell can help you. Identify the time-consuming tasks that exist now and check if PowerShell can reduce the time involved. If a script isn't readily available for a complex task, take the time to create one. A created script is always reusable, and it's best to think of long-term gains rather than a quick fix.
An Irishman based in Hong Kong, Michael O’Dwyer is a business & technology journalist, independent consultant and writer who specializes in writing for enterprise, small business and IT audiences. With 20+ years of experience in everything from IT and electronic component-level failure analysis to process improvement and supply chains (and an in-depth knowledge of Klingon,) Michael is a sought-after writer whose quality sources, deep research and quirky sense of humor ensures he’s welcome in high-profile publications such as The Street and Fortune 100 IT portals.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites