Jump to content

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


Go to solution Solved by jguinch,

Recommended Posts

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

Link to comment
Share on other sites

  • Solution

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

$objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
$objWMIService = $objSWbemLocator.ConnectServer($strComputer,"root\CIMV2",$strUser, $strPassword)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...