Hi There
I am running the below script and getting error running on any server 2012 r2 and up but works on workstations.
Method invocation failed because [System.Object[]] does not contain a method named 'GetVersion'.
Function Get-OSVersion{$signature = $Signature = @"
[DllImport("kernel32.dll")]
public static extern uint GetVersion();
"@
Add-Type -MemberDefinition $signature -Name "Win32OSVersion" -Namespace Win32Functions -PassThru
}
$os = [System.BitConverter]::GetBytes((Get-OSVersion)::GetVersion())
Write-Output $os