just wondering if I may trouble this forum for a sec and is this inquiry came up in the previous closed thread..
I love the services script that uses the array. I can place the hostname of the pc I need services to identify if started or stopped but, I can't seem to run it remotely.. the pc I am on is in a workgroup and I want to get the script to speak to a domain controller in a domain .. will this not work because of the disparate workgroup to domain issue?
script:
ArrComputer = Array("gpcoss")
ArrServices = Array("Alerter", "DHCP Client", "DNS Client")
i = 0
For Each strComputer In ArrComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
For Each Service In ArrServices
If i > 0 Then
str = str & " or DisplayName = '" & Service & "'"
Else
str = "DisplayName = '" & Service & "'"
i = i + 1
End If
Next
Set colItems = objWMIService.ExecQuery("Select DisplayName, State from Win32_Service where " & str)
For Each objItem in colItems
Wscript.echo "DisplayName: " & objItem.DisplayName
Wscript.echo "State: " & objItem.State & VbCrLf
Next
Next
The error I receive is "permission denied: 'get-object'
Would it work assumingly if I joined this computer I am running the script from to the domain that the domain controller is on? or is this an elevated admin based issue?
any guidance would be so great and thank again!
blade
I love the services script that uses the array. I can place the hostname of the pc I need services to identify if started or stopped but, I can't seem to run it remotely.. the pc I am on is in a workgroup and I want to get the script to speak to a domain controller in a domain .. will this not work because of the disparate workgroup to domain issue?
script:
ArrComputer = Array("gpcoss")
ArrServices = Array("Alerter", "DHCP Client", "DNS Client")
i = 0
For Each strComputer In ArrComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
For Each Service In ArrServices
If i > 0 Then
str = str & " or DisplayName = '" & Service & "'"
Else
str = "DisplayName = '" & Service & "'"
i = i + 1
End If
Next
Set colItems = objWMIService.ExecQuery("Select DisplayName, State from Win32_Service where " & str)
For Each objItem in colItems
Wscript.echo "DisplayName: " & objItem.DisplayName
Wscript.echo "State: " & objItem.State & VbCrLf
Next
Next
The error I receive is "permission denied: 'get-object'
Would it work assumingly if I joined this computer I am running the script from to the domain that the domain controller is on? or is this an elevated admin based issue?
any guidance would be so great and thank again!
blade