Skip to content

Instantly share code, notes, and snippets.

@gravcat
Created June 2, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravcat/107dcc6952a194bfb26a08cf735e07c1 to your computer and use it in GitHub Desktop.
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
<# -----------------------------------------------------------------------------
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