#ValidationTags#Messaging,FlowControl,Pipeline,CodeStyle#functionGet-DbaOperatingSystem{<#
.SYNOPSIS
Gets operating system information from the server.

.DESCRIPTION
Gets operating system information from the server and returns as an object.

.PARAMETER ComputerName
Target computer(s). If no computer name is specified, the local computer is targeted

.PARAMETER Credential
Alternate credential object to use for accessing the target computer(s).

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Returns information about the sql2016 and sql2017 operating systems using alternative Windows credentials

.EXAMPLE
PS C:\> Get-Content .\servers.txt | Get-DbaOperatingSystem

Returns information about all the servers operating system that are stored in the file. Every line in the file can only contain one hostname for a server.
#>[CmdletBinding()]param([Parameter(ValueFromPipeline)][Alias("cn","host","Server")][DbaInstanceParameter[]]$ComputerName=$env:COMPUTERNAME,[PSCredential]$Credential,[Alias('Silent')][switch]$EnableException)process{foreach($computerin$ComputerName){Write-Message-LevelVerbose-Message"Connecting to $computer"

$splatDbaCmObject=@{ComputerName=$computerResolvedEnableException=$true}if(Test-Bound"Credential"){$splatDbaCmObject["Credential"]=$Credential}if($TestWS){try{$psVersion=Invoke-Command2-ComputerName$computerResolved-Credential$Credential-ScriptBlock{$PSVersionTable.PSVersion}$PowerShellVersion="$($psVersion.Major).$($psVersion.Minor)"}catch{Write-Message-LevelWarning-Message"PowerShell Version information not available on $computer."$PowerShellVersion='Unavailable'}}else{$PowerShellVersion='Unknown'}

try{$powerPlan=Get-DbaCmObject@splatDbaCmObject-ClassNameWin32_PowerPlan-Namespace"root\cimv2\power"|Select-ObjectElementName,InstanceId,IsActive}catch{Write-Message-LevelWarning-Message"Power plan information not available on $computer."$powerPlan=$null}

try{$ss=Get-DbaCmObject@splatDbaCmObject-ClassWin32_SystemServicesif($ss|Select-ObjectPartComponent|Where-Object{$_-like"*ClusSvc*"}){$IsWsfc=$true}else{$IsWsfc=$false}}catch{Write-Message-LevelWarning-Message"Unable to determine Cluster State of $computer."$IsWsfc=$null}