There are no separate math functions in PowerShell. So when you need
to access a maths function such as Round or Sqrt, just call for the
System.Math. If you have ever wondered about the PowerShell double colon
(::),
then all is revealed, it means a static method.
Note 3: As an alternative I have used [Math] instead of
[System.Math]; the pair seem interchangeable.
Note 4: Incidentally, 'Round' calculates to the
nearest number, which means it will round up. Whereas Truncate just
chops off the decimal places. Thus:
Round $Num = 49.6814343. The result is: 50 Truncate $Num =
49.6814343. The result is: 49
Guy
Recommends: Free WMI Monitor for PowerShell
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft's 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. Give this WMI monitor a
try - it's free.
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.
When you need
to access a maths function such as Round or Truncate, just call for the
System.Math. PowerShell has no separate math functions. There is no
need to create an object for the Math class, simply employ a double colon
(::) before the method.
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.