Avatar of Chris Dent
Chris Dent
Flag for United Kingdom of Great Britain and Northern Ireland asked on

PowerShell and .NET - Calling Methods

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:


And / Or access the values returned with:


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:


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.NetworkInformation.Ping

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 ;)

Microsoft DevelopmentPowershellWindows Server 2003

Avatar of undefined
Last Comment
Chris Dent

8/22/2022 - Mon

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

I meant to note... on the MSDN website. Static Methods are denoted by an comic (ish) font S

A good example is System.Math
Chris Dent

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.


NP.... btw, are you going to be at the Summit?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Chris Dent


Unfortunately not, was really hoping to, but changed job a short while ago and I don't have enough holiday to cover it :(

Instead I'm going with hoping I manage to somehow get re-awarded (July set) so I can head over next year :)