header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Strange get-location behavior in runspace
Last Post 02 May 2008 04:36 AM 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
Avatar

--
24 Apr 2008 07:38 AM

    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
    Avatar

    --
    24 Apr 2008 08:54 AM
    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
    Veteran Member
    Veteran Member
    Posts:1684
    Avatar

    --
    02 May 2008 04:36 AM
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer