Created
June 2, 2017 16:39
-
-
Save gravcat/107dcc6952a194bfb26a08cf735e07c1 to your computer and use it in GitHub Desktop.
a powershell function to check whether or not you are running in a linux (or linux-like) environment. powershell on linux is a thing now
This file contains hidden or 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
<# ----------------------------------------------------------------------------- | |
Check-LinuxOS() | |
.Description | |
Check whether or not a host you are running from is Linux. WMI is not yet | |
available in the PowerShell alpha. | |
----------------------------------------------------------------------------- #> | |
function Check-LinuxOS { | |
$ErrorActionPreference = "SilentlyContinue" # Prevents stop when Windows explodes with uname call | |
if ((& uname -s) -Like "Linux") { | |
return $True | |
} | |
else { | |
return $False | |
} | |
$ErrorActionPreference = "Stop" # Set it back to what we typically want | |
} Export-ModuleMember -Function Check-LinuxOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment