header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Strange get-location behavior in runspace
Last Post 02 May 2008 01:36 PM by marco.shaw. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
JimMcGillUser is Offline
New Member
New Member
Posts:3

--
24 Apr 2008 04:38 PM  

I've written a cmdlet that converts binary records off the trace log into well behaved PSObjects and am having a puzzling input problem. I'd like to allow the user to just put in the file name and have the cmdlet find the file. So the format would be

Get-ETL filename.etl ...

This fails if filename.etl isn't in the root directory. Makes sense, psychic cmdlets aren't part of the current release.

So, as a first approximation, I decided to try picking up the current directory and appending it to the file name by running Get-Location in a runspace. Runs fine, but returns the wrong path. Instead of returning the directory where the cmdlet is running (c:\psd) it returns my home directory (c:\documents and settings\jmcgill). Huh? Anybody got a clue what's going on?

As an alternative, is there some local variable, analogous to $Env, that contains the current directory?

 

JimMcGillUser is Offline
New Member
New Member
Posts:3

--
24 Apr 2008 05:54 PM  
I think I have figured part of the problem but I don't understand how to fix it. When I configure my runspace I do the following:

RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);

So it makes sense it opens the runspace in my root directory. Which explains why I'm getting the unexpected directory in the return. This brings me back to the second option in my original posting - how do I figure out what the current directory that the cmdlet is executing in is?
marco.shawUser is Offline
Co-Community Director
Basic Member
Basic Member
Posts:177

--
02 May 2008 01:36 PM  
This help any?
http://decav.com/blogs/andre/archive/2008/05/01/invoking-powershell-scripts-from-an-application.aspx
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer