I'm attempting to translate the following bit of code from this vbs script.
code:
 Set OpSysSet=GetObject("winmgmts:{(Debug,RemoteShutdown)}//" _
& ComputerName & "/root/cimv2").ExecQuery( _
"Select * from Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Win32Shutdown(x)
Next

Unfortunantly I know as much about COM as I know about VBS.

Here are a couple of my attempts. Please let me know where I am going wrong.

code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2")
.ExecQuery("Select * from Win32_OperatingSystem where Primary=true")
For Each $OpSys in $ObjShutdown
$execut = $OpSys.Win32Shutdown(4)
Next

code:
$ObjShutdown = GetObject("winmgmts:{(Debug,RemoteShutdown)}!\\computername\root\cimv2")
$OpSysSet = $ObjShutdown.ExecQuery("Select * from Win32_OperatingSystem where Primary=true")
For Each $OpSys in $OpSysSet
$execut = $OpSys.Win32Shutdown(4)
Next

Thanks