I meant to note... on the MSDN website. Static Methods are denoted by an comic (ish) font S
A good example is System.Math
http://msdn2.microsoft.com
Main Topics
Browse All Topics
Busily chipping away at understanding PowerShell, but being a complete non-programmer occasionally makes things really odd...
Anyway, perhaps some one already knows this one and I can stop trying to make up reasons.
I really like having access to the .NET Framework, really quite shiny and can do things that were a pain in the proverbial in VbScript. But...
When using classes and their associated methods in the .NET Framework how do you know how to properly call them (in advance, without my usual Trial and Error approach)?
For example, I can call a method in the DNS class like this:
[System.Net.DNS]::GetHostB
And / Or access the values returned with:
([System.Net.DNS]::GetHost
All fine so far, but then I go and pick on another class, we'll take Ping this time, sticking in the networking theme. Because it's somewhat consistent I wanted to do this:
[System.Net.NetworkInforma
Send being the method under the Ping class that seemed entirely sound. Doesn't work, of course. Instead I have to create an object:
$Ping = New-Object System.Net.NetworkInformat
$Ping.Send("<IP>")
So, hmmm, anyone happen to know why? If it's not a horribly long answer involving many concepts that I just don't want to get ;)
Chris
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I meant to note... on the MSDN website. Static Methods are denoted by an comic (ish) font S
A good example is System.Math
http://msdn2.microsoft.com
I pulled it from the MSDN site originally, but erm, I've kind of been ignoring those symbols in the first column. I have a bad habit of skimming things in the expectation that I'll manage to populate the blank spaces automatically, honestly it does work sometimes ;)
Thanks very much though, it does indeed explain it very neatly :)
Back to attempting to avoid writing VbScript.
Chris
Business Accounts
Answer for Membership
by: BSonPoshPosted on 2008-04-11 at 08:44:19ID: 21335332
First... Let me tell you I am NOT a developer... never was and never will be :) That said while learning Powershell I have learned some qwerks of .NET. One of those qwerks is a static method.
/en-us/lib rary/ syste m.net.netw orkinforma tion.ping. aspx
s/wordpres s/?p=10
A static method is a function that can be call on a class without having to create and instance of a class. In your case you were calling ping() as if it is a static method using [type]::Method().
If you look at the class http://msdn2.microsoft.com
It does not have any static methods. This means you have to create an instance of the class using the New-Object CMDLet
For future... Learning to use the MSDN website has help tremendously and understanding some of the trivial developer terms that go with it...
I have a blog post here that covers the basics. Its old.. I should update it :)
http://bsonposh.com/module