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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
True. It works for me :) I also have two versions of profile
psrc
andpsrcmin
. My profile always loadspsrcmin
on my devbox.