Skip to content

Instantly share code, notes, and snippets.

@vors
Created December 16, 2014 03:12
Show Gist options
  • Save vors/b30a2f835e64a8a00329 to your computer and use it in GitHub Desktop.
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 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
}
@vors
Copy link
Author

vors commented Jan 13, 2015

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