Not-Working
--------------
$citrix="server002","server003"
Get-WmiObject Win32_Service -Filter "Name='print spooler'" -computer
$citrix| ft SystemName,Name ,state -a
Anytime the service has multiple words, it just returs the PS> prompt. No
go. Why?
This just comes does to a difference between the "Name" and
"DisplayName" properties:
PS>gwmi win32_service
name displayname
---- -----------
...
Spooler Print Spooler
So, you're filtering on the name property, but using the value from
display name instead.
You need to do:
Get-WmiObject Win32_Service -Filter "DisplayName='print spooler'"...
Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp
PowerGadgets MVP
http://www.powergadgets.com/mvp
So this is a machine you've never connected to? It possibly has the
Windows Firewall enabled to block these remote calls.
Source: http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx
0x80070005 (DCOM ACCESS_DENIED)
This error occurs when the connected user is not recognized or is
restricted in some fashion by the remote server (for example, the user
might be locked out). This happens most often when accounts are in
different domains. Recent changes to WMI security can also cause this
error to occur:
• Blank passwords, formerly permitted, are not allowed in Windows XP and
Windows Server 2003.
• WMI does not allow asynchronous callbacks to a Windows 98 client. A
call like SWbemServices.ExecNotificationQueryAsync from a Windows 98
computer to a Windows XP computer will result in an Access Denied error
returned to the Windows 98 machine.
• The DCOM configuration access setting might have been changed.
• If the target computer is running Windows XP, the Forceguest value
under the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa might be set to
force the Guest account off (value is zero).
IE Go from:
-----------------
PS C:\scripts> .\alerter.ps1
SystemName Name state
---------- ---- -----
GCCSM032 Dnscache Running
GCCSM033 Dnscache Running
GCCSM034 Dnscache Running
GCCSM035 Dnscache Running
SystemName Name state
---------- ---- -----
GCCSM032 Spooler Running
GCCSM033 Spooler Running
GCCSM034 Spooler Running
GCCSM035 Spooler Running
TO>
PS C:\scripts> .\alerter.ps1
SystemName Name state Name state
---------- ---- ----- -------- ------
GCCSM032 Spooler Running Dnscache Running
GCCSM033 Spooler Running Dnscache Running
GCCSM034 Spooler Running Dnscache Running
GCCSM035 Spooler Running Dnscache Running
You can use the OR operator inside the filter parameter:
Get-WmiObject Win32_Service -Filter "Name='alerter' or Name='W3SVC' or Name='Spooler'"
| ft SystemName,Name ,state -a
-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
> Ok how can I take the listing of several services off a server and
> display them together?
>
> IE Go from:
> -----------------
> PS C:\scripts> .\alerter.ps1
> SystemName Name state
> ---------- ---- -----
> GCCSM032 Dnscache Running
> GCCSM033 Dnscache Running
> GCCSM034 Dnscache Running
> GCCSM035 Dnscache Running
> SystemName Name state
> ---------- ---- -----
> GCCSM032 Spooler Running
> GCCSM033 Spooler Running
> GCCSM034 Spooler Running
> GCCSM035 Spooler Running
You can also use LIKE. This will get all service names that starts with 's':
Get-WmiObject Win32_Service -Filter "Name like 's%'"
How to get this working?
---------------------------------------------------
$citrix=Get-Content C:\Scripts\servers1.txt
$services=Get-Content C:\Scripts\services.txt
get-wmiobject win32_service -filter "name='$services'" -computer $citrix |
ft SystemName,Name,state -a
WQL (SQL for WMI)
http://msdn2.microsoft.com/en-us/library/aa394606(VS.85).aspx
-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
> Im not looking for services with similar names, Im trying to get a
> specific list of services on a specific set of servers.
>
> See my double array question - stil open.
>
Correct me if I am wrong.. arent you looking to have each server on one
line?
"Ian_1" <fake...@nodomain.com> wrote in message
news:9941B9A0-11A6-4417...@microsoft.com...
> OK so my script has evolved.
>
> Im trying to use 2 array's now, but trying to figure out how to make it
> work. Any suggestions?
>
> -------------------------------------------------
>
> $citrix=Get-Content C:\Scripts\servers1.txt
> $services=Get-Content C:\Scripts\services.txt
>
> get-wmiobject win32_service -filter "name='$services'" -computer
> CBR10606281
> | ft SystemName,Name ,state -a
###################################
$citrix=Get-Content C:\Scripts\servers1.txt
$services=Get-Content C:\Scripts\services.txt
foreach($computer in $citrix)
{
$myobj = "" | Select-Object Name
$myobj.Name = $computer
foreach($service in $services)
{
$result = Get-WmiObject Win32_Service -Filter
"Name='$service'" -computer $computer
$myobj | add-Member -MemberType NoteProperty -Name $Service -value
$result.state
}
$myobj |Format-Table *
}
"Ian_1" <fake...@nodomain.com> wrote in message
news:0D2CC01B-9296-4E98...@microsoft.com...