You may already know that you can access the core .NET libraries like System.Math from PowerShell:
As “System” is the default namespace, you could just type [Math]::Sqrt(2).
But what if you wanted to do a quick financial calculation from PowerShell? Maybe calculate the monthly payment for the classic Mustang you just just have to have? Just use the Visual Basic financial library. In the example below, at 5% (.05/12 per month), over five years (5*12 payments) and an amount of 20,000, your payment would be 377.42 per month. (The minus sign is what it will do to your checking account.)
Find the available methods…
While you could search MSDN for a list of methods available from these libraries, you could also just ask the library! Just call the GetMethods() method!
As the Math library includes both Methods and Fields (constants in this case) you would use GetMembers() instead.
What else is in the VB library?
Do some browsing by typing “[Microsoft.VisualBasic.” and pressing Tab. When you find something interesting then add the closing square bracket and add .GetMembers() and see what’s there. For example, [Microsoft.VisualBasic.Constants] provides a list of constants like vbOK and vbCancel.
.
No comments:
Post a Comment