This
section is dedicated to explaining PowerShell's individual syntactic elements. I
also regard these topics as reference material for that time when you forget how to choose the correct type of bracket, or
when a single quote does not get the job done.
At first glance, one of the strangest comparison operator in PowerShell
is -eq. While the equals sign '=' is still needed for declaring
variables, in most other cases you need -eq, or for PowerShell not equal -ne.
Once you warm to this theme, then -gt -lt seem a logical continuation.
Consequently, abandon > and <, instead employ -gt (greater than) or -lt
(less than).
# PowerShell script to list .exe under the Windows folder
$Dir = Get-Childitem C:\windows\ -recurse $List =
$Dir | where {$_.extension -eq ".exe"} $List | Format-Table Name,
CreationTime -auto
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems. Fortunately, Solarwinds
have created a
Free WMI Monitor so that you can discover these gems of performance
information, and thus improve your PowerShell scripts. Take the guess work out of which WMI counters to use when scripting the
operating system, Active Directory or Exchange Server.
Each topic has its own 'how to' instructions and also 'Learning points'.
As a result you will be able to modify my examples to suit your situation. The only pre-requisite is that
you must download the correct version of PowerShell and .Net Framework for your operating system. Microsoft's site has separate versions
of PowerShell for XP, Windows Server 2003 and Vista. In the case
of Windows 7 and Server 2008, PowerShell is built-in but you need to 'Add
Feature'.
The pages in this section will help you with PowerShell's individual syntactic elements. I regard these topics as reference material for that time when you forget how to choose the correct type of bracket, or
when a single quote does not get the job done.
Another use of this page is to investigate new parameters or switches for well-known commands, for example
-recurse as in: Get-Childitem -recurse.
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 one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.