PowerShell Team

Automating the world one-liner at a time…

How can a script tell what directory it was run from?

PSMDTAG:FAQ: How can a script determine what directory it was invoked from?PSMDTAG:FAQ: What is $MyInvocation?PSMDTAG:FAQ: Why is $MyInvocation.ScriptName empty? Create 2 scripts (First.PS1 and Second.PS1) to explore what is going on with $MyInvocation and how you can use it to determine what directory a script was invoked from: PS> cat ...

Use of Preference Variables to control behavior of streams

PSMDTAG:FAQ: Why don't I see output when I use Write-Verbose and Write-Debug?PSMDTAG:SHELL: Use of Preference Variables to control behavior of streams. In Windows PowerShell, the WRITE-XXX cmdlets merely sends things to a Named stream.  You then have user-defined preferences for what to do when things appear on that stream.  Alex ...

Perserving Command History Across Sessions

<Edited 7/2/2006 to add tags and Categories> Ben Winzenz didn't like the fact that Windows PowerShell did not maintain history lists between sessions (http://winzenz.blogspot.com/2006/06/cool-mshpowershell-tidbit.html) .   We hear you Ben.  Back to my least favorite phrase, "to ship is to choose".  That said, we ...

Listing all the COM automation PROGIDs

<edited 7/2/2006 to add categories and PSMDTAGs> Windows PowerShell allows you to program against COM automation.  The typical way to do this is : $x = new-ojbect -ComObject <PROGID> The question then is, how do I know what progids I can use.  Here are there 3 answers I'm lucky enough to be in category 3 so I'll ...

Finding the static methods of a class

<Edited 7/2/2006 to add categories and tags> In the previous entry, it showed how you could use the static method GetHostAddresses of the [System.Net.Dns] class to resolve a hostname.  This begs the question, how do you find the static methods of a class.  There are 2 answers to this: 1) SDK documentation.  (remember the ...

Windows PowerShell One Liner: Name to IP Address

<Edited 7/2/2006 to add tags and category>Wei Wu provided a nice one liner in response to a query in our NewsGroup: Microsoft.Public.Windows.PowerShell about how to resolve a hostname into an IP Address: PS> [System.Net.Dns]::GetHostAddresses("www.msn.com") IPAddressToString : 207.68.173.76Address      &...

Improved Support for WMI

<Edited 7/2/2006 to add tags and categories>We have recently completed work on improved support for WMI including: Everyone that uses WMI owes a debt of gratitude to Greg Ramsey.  Greg did an MMS session and lab focused on Scripting SMS using VBscript and Windows PowerShell.  Jim Truher and I joined Greg to host a Birds...

Managing Active Directory with Windows PowerShell

MOW is now posting the details of his Managing Active Directory with Windows PowerShell demo that he performed at my TechEd talk.  This is worthwhile for everyone to review.  For the people at the talk, we covered a huge amount of data in a very short time so it would be worth while to walk through the details.  For ...