Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 182126

Set starting directory in PowerCLI

$
0
0

So this may be a bit pedantic, but I'm sure others understand how you start trying to do something simple and it snowballs into a much larger issue.

 

Well, I wanted to set the default directory I start in when I launch PowerCLI instead of the default C:\. I started with adding a 'cd C:\path\' in a generic Powershell profile file. However, this didn't work.

 

But my normal Powershell consoles were starting in the correct path, so I figured it must be something happening with PowerCLI specifically. So I looked in 'Initialize-PowerCLIEnvironment.ps1' and saw a 'cd \' around line 269 (PowerCLI 6.0R3). This appeared to be the culprit.

 

In accordance with the documentation, instead of modifying the default Initialize file and possibly messing up the signature, I then tried to create a custom 'Initialize-PowerCLIEnvironment_Custom.ps1' file and added 'cd C:\path\' to that. According to the documentation, "The application recognizes and loads the custom file after loading the default script configuration file."  However, again, this didn't work.

 

Looking back at the default Initialize script, I noticed that the 'cd \' is actually located AFTER it runs the custom init script (lines 264-267).

 

So it seems this 'cd \' is pretty much the LAST thing that will run before you get a prompt. So the only option I could find, despite the documentation's warning, was to modify the default Initialize script.

 

Is there a more elegant approach to this I'm overlooking? Why does this set a default directory at all - especially at that point in the initialization? This almost feels like a development line that was supposed to be removed before publishing, but was overlooked.


Viewing all articles
Browse latest Browse all 182126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>