Jump to content
Sign in to follow this  
yosvanyisel

I need to get the domain name of a remote computer using the principle of your example using user credentials

Recommended Posts

yosvanyisel

please could help me. I need to get the domain name of a remote computer using the principle of your example using user credentials. similar to this.
the problem is that the example I have returned empty string me when I enter the name of a network computer

Func DomainComputerBelongs($strComputer = "localhost")
; Generated by AutoIt Scriptomatic
$Domain = ''
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20

$objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
If Not IsObj($objWMIService) Then Return SetError(1, 0, '')
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
For $objItem In $colItems
$Domain = $objItem.Domain
Next
Endif
Return $Domain
EndFunc

Share this post


Link to post
Share on other sites
jguinch

You can specify the login/password with something like this :

$objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
$objWMIService = $objSWbemLocator.ConnectServer($strComputer,"root\CIMV2",$strUser, $strPassword)
  • Like 1

Share this post


Link to post
Share on other sites
yosvanyisel

PERFECT THANKSSSSS  !!!!!!!!!!!!!!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×