It seems you know how to assign variables, so I'm not sure what the hang up is here. You would simply run the GWMI command as the value of a variable such as:
$Results = get-wmiobject -namespace root\CIMV2 -class Win32_OperatingSystem -computername $servername
Then reference the properties of the object you just created such as:
$Results.SystemDirectory
$Results.caption
$Results.BuildNumber