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]::GetHostByAddress("")
And / Or access the values returned with:
([System.Net.DNS]::GetHostByAddress("")).HostName
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.NetworkInformation.Ping]::Send("P>")
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 $Ping.Send("")
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
|