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! 🙂



Leave a Comment

You must be logged in to post a comment.

blank