How can I determine the OS type, (Linux, Windows) using Powershell from within a script?
The ResponseUri isn't recognised when this part of my script is ran on a Linux host.
$UrlAuthority = $Request.BaseResponse | Select-Object -ExpandProperty ResponseUri | Select-Object -ExpandProperty Authority
So I want an If
statement to determine the OS type that would look similar to this:
If ($OsType -eq "Linux")
{
$UrlAuthority = ($Request.BaseResponse).RequestMessage | Select-Object -ExpandProperty RequestUri | Select-Object -ExpandProperty host
}
Else
$UrlAuthority = $Request.BaseResponse | Select-Object -ExpandProperty ResponseUri | Select-Object -ExpandProperty Authority
I could use Get-CimInstance Win32_OperatingSystem
but it would fail on Linux as it's not recognised.