If you use the PowerShell prompt a lot and/or the PowerShell ISE, you might find your life made a little bit easier by setting up a PowerShell Profile.
All they are is a script that’s run each time you open the powershell.exe prompt or the powershell_ise.exe ISE (or both). You can put anything you like in them, e.g. adding the VMware PowerCLI snapins, setting the current folder, whatever. Note that $profile points to different files for the prompt vs the ISE.
The file is referenced via the built in variable $profile, which actually has several different options depending on whether you want the profile script to run for the PowerShell prompt, the ISE, both, the current user, any user on the PC, etc. Personally, I find the most useful one is the CurrentUserAllHosts, which means it runs for both the prompt and the ISE.
The WindowsPowerShell folder doesn’t exist, but we can create that and an empty profile script with New-Item:
New-Item -Path $profile.CurrentUserAllHosts -ItemType File -Force
If you’re in the ISE, you can then edit your new profile script by using:
You might like to create a “Scripts” folder in your user profile, and then use the profile to set that as a PSDrive and change to it:
New-PSDrive -Name Scripts -PSProvider FileSystem -Root $env:USERPROFILE\Scripts Set-Location -Path Scripts:\
Obviously, depending on what you put in your $profile it might delay your PowerShell startup experience somewhat.