The Power of Windows PowerShell
Windows PowerShell is a command-line shell and scripting language that helps administrators improve their productivity in day to day management tasks and achieve greater control over their IT environments. Using a new admin-focused scripting language, more than 230 standard command-line tools, and consistent syntax and utilities, Windows PowerShell allows admins to more easily control system administration and accelerate automation.
PowerShell ships with the Windows 7 and Windows Server 2008 R2. However if you’re running Windows XP or Windows Vista, you are still able to download a standalone installer for PowerShell.
PowerShell or as I’m going to call it PS for shorten, won’t replace the existing CMD “Command Prompt” already in Microsoft Windows. PS has CMD included within it in order to let admins do all tasks through the same environment.
PS is considered an intermediate environment that is a perfect choice for both Developers and IT Professionals as well. Since a developer can do some system procedures using PowerShell depending on “CMDLETS”. CMDLETs are .NET classes that represent APIs and GUIs. While IT Professionals can do a delicate scripting commands that became pretty more easier than other scripting languages like JavaScript and VBScript.
For example, if we’d like to list Inactive Services in a running instance of Windows, we can write the procedure as:
For VBScript
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=Impersonate}!\\" &
strComputer & _
"\root\cimv2")
Set colStoppedServices = objWMIService.ExecQuery _
("Select * From Win32_Service Where State <> 'Running'")
For Each objService in colStoppedServices
Wscript.Echo objService.DisplayName & " = " & objService.State
Next
For Windows PowerShell
get-service |where {$_.status –ne “running"} | ft displayname,status –au
Any easier?! :)
Why PowerShell?
Productivity
- Consistent syntax and approach – learn once apply many times
- Frictionless Composition – Type what you think
- Flexible system – works against the “old” and the “new”
Fun
- Multiple ways to administer tasks – interactive, scripting, API, GUI
- Makes Windows administration as pleasant/productive/cool as possible
Sharing
- Enables an ecosystem where the community can effectively fill in the things we’ve missed
This was the first article of a series I’m going to present about Windows PowerShell in the next few days. Follow up!