Skip to content

Instantly share code, notes, and snippets.

@gravejester
Created May 28, 2015 17:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gravejester/3733c2f8478dd86c7821 to your computer and use it in GitHub Desktop.
Save gravejester/3733c2f8478dd86c7821 to your computer and use it in GitHub Desktop.
function Invoke-PowerShell {
powershell -nologo
Invoke-PowerShell
}
function Restart-PowerShell {
if ($host.Name -eq 'ConsoleHost') {
exit
}
Write-Warning 'Only usable while in the PowerShell console host'
}
Set-Alias -Name 'reload' -Value 'Restart-PowerShell'
$parentProcessId = (Get-WmiObject Win32_Process -Filter "ProcessId=$PID").ParentProcessId
$parentProcessName = (Get-WmiObject Win32_Process -Filter "ProcessId=$parentProcessId").ProcessName
if ($host.Name -eq 'ConsoleHost') {
if (-not($parentProcessName -eq 'powershell.exe')) {
Invoke-PowerShell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment