Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remotely obtain services running from pc not in same domain 1

Status
Not open for further replies.

blade1000

IS-IT--Management
Mar 1, 2009
133
US
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
 
from the scripting guys website

Const WbemAuthenticationLevelPktPrivacy = 6

strComputer = "atl-ws-01"
strNamespace = “root\cimv2”
strUser = "Administrator"
strPassword = "4rTGh2#1"

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objwbemLocator.ConnectServer _
(strComputer, strNamespace, strUser, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy

Set colItems = objWMIService.ExecQuery _
("Select * From Win32_OperatingSystem")
For Each objItem in ColItems
Wscript.Echo strComputer & ": " & objItem.Caption
Next
 
Thanks Mrmovie,

that did in fact help, it returned back the NOS version I am running but how can I add services and see if they are started or stopped, like SQL, or a specifc app that runs as service..

any help would be greatly appreciated, am researching syntax to add to script now.

thx
blade
 

You need to query the appropriat database. MrMovie's example query's the :win32_OperatingSystem" database. There are so many databases to discover. Just google "win32_" and check out MSDN.

For processes, query the Win32_Process db:
Set colItems = objWMIService.ExecQuery ("Select * From Win32_Process")

Or the BIOS:
Set colItems = objWMIService.ExecQuery ("Select * From Win32_BIOS")

How about Computer configuration:
Set colItems = objWMIService.ExecQuery ("Select * From Win32_ComputerSystem")

-Geates
 
it's obvious I don't look at the screen when I type. The colon is a typo

:win32_OperatingSystem
 
Thanks Geates, awesome -have a star!!!!

blade
 
Everywhere I "go" I seem to be aquiring stars. Whether it be from forums, StarGrams at work (yes..."StarGrams"), or those I earn which suggest my ability to play fake instruments (Guitar Hero reference). Thanx.

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top