So OK ?
ZitatKann ich die Abfrage auf den lokalen PC, bzw. vielleicht sogar auf die beiden lokalen Gruppen "Benutzer" und "Administratoren" beschränken?
Ist schon auf lokalen PC beschränkt: $strComputer = "localhost"
Spoiler anzeigen
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$check_local_admin = 0
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_GroupUser", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
If ( StringInStr($objItem.GroupComponent,"Administratoren") ) Or _
( StringInStr($objItem.GroupComponent,"User") ) Then
If StringInStr($objItem.PartComponent,"admin_ntt") Then
$check_local_admin = 1
ExitLoop
EndIf
EndIf
Next
If $check_local_admin = 1 Then
MsgBox(0,"","User admin_nt existiert bereits!")
Else
MsgBox(0,"","User admin_nt existiert noch nicht!")
EndIf
Else
Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_GroupUser" & @CRLF & "It is not possible to check if the local admin user 'admin_nt exists" )
Endif