On Vista and later on operating systems PowerShell supports database
style 'ACID' transactions, whereby you can commit or roll-back a
sequence of operations.
PowerShell Modules
Import-Module loads a bunch of dll and scripts, it replaces the
Add-PSSnapin. See more about the
PowerShell modules directory.
#REQUIRES -version 2.0
This is not merely a remark, but an instruction to PowerShell v 1.0
that it cannot run the code which follows.
# PowerShell 2.0 Requires Example # Requires -version 2.0 Enter-PSSession IpAddress or FQDM
Research Techniques for Finding New PowerShell 2.0 Cmdlets
One way of checking for new PowerShell 2.0 cmdlets is to use Get-Command
with the -Noun or -verb parameter. For example I heard a rumour there
was a new measure cmdlet.
Research Measure-Object
# Research measure cmdlets Clear-Host
Get-Command -verb measure
Research New Event cmdlets
# Research new event Windows PowerShell 2.0 cmdlets Clear-Host
Get-Command -commandType cmdlet *Event*
Note: Get-WinEvent
List All Cmdlets
# Research new Windows PowerShell 2.0 cmdlets Clear-Host
Get-Command -CommandType Cmdlet
SolarWinds Firewall Browser
Here is an utility where you can review firewall settings such as
access control lists (ACL), or troubleshoot problems with network
address translation (NAT).
Other reasons to download this SolarWinds Firewall Browser include
managing requests to change your firewall settings, testing firewall
rules before you go live, and querying settings with the browser's
powerful search options.
Think of learning PowerShell as a more convenient method of configuring the server than using the corresponding GUI. I can foresee running
PowerShell scripts that will diagnose server problems. With
PowerShell you can run queries
that are not possible from the GUI. On a good
day such a script would even cure the problem - magic!
To come back down to earth, let us
start with a trivial example to illustrate the capability of PowerShell. As you may know, the Task Manager will display all the processes, yet with
PowerShell you can
not only list all processes, but also group them by company (Microsoft, HP
and Roxio). All you need is this one-liner:
Get-Process | group-Object company
PowerShell will achieve the same results as VBScript, but with fewer commands.
For instance, PowerShell makes scripting WMI much easier, for example,
try: Get-WmiObject win32_BIOS.
More good news, you can even use PowerShell to replace VBScript for Active Directory scripts.
I
have a sense that there is a changing of the guard; out with old CMD commands, and in with new
PowerShell language. More importantly, the new PowerShell language will give you command line control
of the Windows operating system; this is similar to the power that Bash
commands exert over the UNIX operating system.
In a nutshell:
PowerShell really is the way of the future.
The main
reason for learning PowerShell is so that you can administer Exchange Server 2007,
and also the Longhorn server that will succeed Windows Server 2003.
Microsoft's thinking is that the point has arrived where complex
products like Exchange and Longhorn have so many menus and sub-menus to
configure via a GUI, that we need an alternative. Hence the easy-to-use scripting language
called PowerShell.
Note: Existing Windows executables, such as Ipconfig and ping, perform in the PS Shell just as they do in the old CMD 'DOS box'.
Guy Recommends: A Free Trial of the Network Performance Monitor
(NPM)
SolarWinds'
Network Performance Monitor
will help you discover what's happening on your network. This
utility will also guide you through troubleshooting; the dashboard will
indicate whether the root cause is a broken link, faulty equipment or
resource overload.
What I like best is the way NPM suggests solutions to network
problems. Its also has the ability to monitor the health of individual VMware
virtual machines. If you are interested in troubleshooting, and creating
network maps, then I recommend that you try NPM now.
Preamble, Start, Run PowerShell. At the command line type (In that dark blue shell):
Get-Service
Here is another example, type: Get-WmiObject win32_computersystem
I first realised the ability of
PowerShell when I saw three lines of PowerShell replace about
twenty
lines of VBScript. The task is to interrogate Win32_classes, we can either use the traditional VBScript and WMI, or the new
PowerShell with its verb-Noun commands.
VBScript
Windows PowerShell
' Memory.vbs ' VBScript to discover how much RAM in computer ' Author Guy http://computerperformance.co.uk/ ' Version 1.3 - August 2005 '
-------------------------------------------------------' Option Explicit Dim objWMIService, objComputer, colComputer Dim strLogonUser, strComputer strComputer = "." Set objWMIService =
GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colComputer = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each
objComputer in colComputer Wscript.Echo "System Name: " & objComputer.Name _ & vbCr & "Total RAM " & objComputer.TotalPhysicalMemory Next
WScript.Quit
' End of Sample Memory WMI / VBScript
# Windows PowerShell script # Displays ComputerName and memory $CompSys = Get-WmiObject win32_computersystem
Remoting is the big new feature of PowerShell v 2.0 followed closely by
the ISE which makes writing scripts so much easier. Other than that,
there lots of neat extra cmdlets.
If you like this page then please share it with your friends
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.
Windows Management Instrumentation (WMI) is
most useful for PowerShell scripting.
SolarWinds
have produced this
Free WMI Monitor to take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.