Last active
April 29, 2020 09:58
-
-
Save codykonior/989e7762d8d069b715f31aaa29ba3b07 to your computer and use it in GitHub Desktop.
Determine whether something can accept user input or not
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 Get-Interactive { | |
[CmdletBinding()] | |
param ( | |
) | |
-not ( | |
<# Jenkins and other services #> | |
$false -eq [Environment]::UserInteractive -or | |
<# Invoke-Command -ComputerName is ASSUMED to be non-interactive #> | |
$Host.Name -eq 'ServerRemoteHost' -or | |
<# RSJob, Workflow #> | |
$null -eq $Host.UI.SupportsVirtualTerminal -or | |
<# PowerShell -NonInteractive #> | |
[Environment]::GetCommandLineArgs() -like '-NonI*' | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment