Archive for December 18th, 2008

You’re Not Where You Think You Are…

Scripting December 18th, 2008

I was writing a quick script to get the Group Policy Health status (using the free Get-SDMGPHealth cmdlet from SDM Software) from computers in various OU’s in my domain.

One option for output from the Get-SDMGPHealth cmdlet is as an XML Document, which is a type of object.  One of the methods (actions an object can take) on the XML Document is the Save() method.  The Save() method does exactly what it says.. it saves the XML Document object as an XML file.

I was using the PowerShell Plus script editor and the interactive console showed my working directory as “C:\documents and settings\myaccount\”.  I ran the script and did a directory listing (I was saving the output with a file name of  “computer name”.xml), but did not see any output.  I ran it again and again, but nothing was writing to the current directory.

I remembered a post that Joel “Jaykul” Bennet wrote about the “Current Directory” problem in PowerShell.  Joel posts an interesting explanation of this issue, as well as a great solution to this problem by modifying the PowerShell prompt function. 

Scenarios where this issue can be a problem is when you are providing a relative path to a .NET method call (which will resolve the full path by using what it sees the Current Directory as).  If you want to avoid all of this, you could pass in full paths (the Resolve-Path cmdlet comes to mind).

Now, you will know where you are! 🙂

MOR 80 – Zero-Days ’til Christmas

Podcast December 18th, 2008

Recorded: December 17, 2008
Your Host: Steve Murawski and Keith Albright
Show Length: 1:26:52

This show is brought to you by Quest and Idera.

When it comes to scripting, you’re a warrior. But mighty warriors need mighty tools!

For awesome PowerShell scripting, nothing matches the might of Quest’s PowerGUI?. Versatile and easy to use, PowerGUI? helps you build commanding scripts that leverage PowerShell’s strength across the enterprise. Now, ruling your domain is easier than ever.

Is your scripting might equal to the challenge? Put the power in your hands. Download PowerGUI today.

Links:

Read the full show notes here.

NEW! View the UStream chat log here.

Website Picks

Keith TED – Technology Entertainment Design – Great videos by smart people on fascinating topics.

Automate your admin tasks FAST with Idera’s PowerShellPlus – THE Power Tool for PowerShell. Download a free 14-day trial at www.Idera.com/PowerShellPlus

Listen Now:

Download Here

blank