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
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