Created
December 16, 2014 03:12
-
-
Save vors/b30a2f835e64a8a00329 to your computer and use it in GitHub Desktop.
Sample of $profile.CurrentUserAllHosts file that can be used to load profile only when session is interactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is $profile.CurrentUserAllHosts file | |
function Get-IsSessionIntaractive() { | |
$parentProcess = Get-Process -id (Get-WmiObject Win32_Process -Filter "ProcessId = '$pid'").ParentProcessId | |
$parentProcess.Name -eq "explorer" | |
} | |
# put your profile in this file and access it with $psrc instead of $profile | |
$psrc = 'C:\Users\sevoroby\Documents\WindowsPowerShell\psrc.ps1' | |
if (Get-IsSessionIntaractive) | |
{ | |
. $psrc | |
} |
True. It works for me :) I also have two versions of profile psrc
and psrcmin
. My profile always loads psrcmin
on my devbox.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesn't quite work. Run PowerShell from cmd (lots of people do this), or PowerShell from PowerShell (doing this interactively is less common, useful for testing assemblies that are already loaded into the current instance.)