<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I can't see that this code gets anything more than Get-Service -
since Get-Service is an interface to
[System.ServiceProcess.ServiceController]<br>
<br>
Some of the info can be derived from the registry or running SC.EXE
- registry interpretation requires information about enumerations
for various keys, SC would require parsing output. Neither gives you
information about the running process if there is one which also
used by the client.<br>
<br>
Looks like no way of getting away from the overhead of WMI - digging
around for extra information or messing around with unstructured
text will get you so far, but not all the info sought.<br>
<br>
David.<br>
<br>
PS C:\WINDOWS\system32\windowspowershell\v1.0> Get-WmiObject
-Filter "Name='dnscache'" win32_service | fl *<br>
<br>
<br>
Name : Dnscache<br>
Status : OK<br>
ExitCode : 0<br>
DesktopInteract : False<br>
ErrorControl : Normal<br>
PathName : C:\WINDOWS\system32\svchost.exe -k
NetworkService<br>
ServiceType : Share Process<br>
StartMode : Auto<br>
__GENUS : 2<br>
__CLASS : Win32_Service<br>
__SUPERCLASS : Win32_BaseService<br>
__DYNASTY : CIM_ManagedSystemElement<br>
__RELPATH : Win32_Service.Name="Dnscache"<br>
__PROPERTY_COUNT : 25<br>
__DERIVATION : {Win32_BaseService, CIM_Service,
CIM_LogicalElement, CIM_ManagedSystemElement}<br>
__SERVER : ITMANSV<br>
__NAMESPACE : root\cimv2<br>
__PATH :
\\ITMANSV\root\cimv2:Win32_Service.Name="Dnscache"<br>
AcceptPause : False<br>
AcceptStop : True<br>
Caption : DNS Client<br>
CheckPoint : 0<br>
CreationClassName : Win32_Service<br>
Description : Resolves and caches Domain Name System
(DNS) names for this computer. If this service is stopped, this
computer will not be able to resolve DNS names and locate Active
Directory domain controllers. If this service is disabled, any
services that explicitly depend on it will fail to start.<br>
DisplayName : DNS Client<br>
InstallDate : <br>
ProcessId : 872<br>
ServiceSpecificExitCode : 0<br>
Started : True<br>
StartName : NT AUTHORITY\NetworkService<br>
State : Running<br>
SystemCreationClassName : Win32_ComputerSystem<br>
SystemName : ITMANSV<br>
TagId : 0<br>
WaitHint : 0<br>
Scope : System.Management.ManagementScope<br>
Path :
\\ITMANSV\root\cimv2:Win32_Service.Name="Dnscache"<br>
Options : System.Management.ObjectGetOptions<br>
ClassPath : \\ITMANSV\root\cimv2:Win32_Service<br>
Properties : {AcceptPause, AcceptStop, Caption,
CheckPoint...}<br>
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS,
__DYNASTY...}<br>
Qualifiers : {dynamic, Locale, provider, UUID}<br>
Site : <br>
Container : <br>
<br>
<br>
<br>
<br>
_______________________________________________________________________________________________________________________________________________<br>
PS C:\WINDOWS\system32\windowspowershell\v1.0> Get-Service
dnscache | fl *<br>
<br>
<br>
Name : dnscache<br>
RequiredServices : {Tcpip}<br>
CanPauseAndContinue : False<br>
CanShutdown : False<br>
CanStop : True<br>
DisplayName : DNS Client<br>
DependentServices : {}<br>
MachineName : .<br>
ServiceName : dnscache<br>
ServicesDependedOn : {Tcpip}<br>
ServiceHandle : SafeServiceHandle<br>
Status : Running<br>
ServiceType : Win32ShareProcess<br>
Site : <br>
Container : <br>
<br>
<br>
<br>
<br>
_______________________________________________________________________________________________________________________________________________<br>
PS C:\WINDOWS\system32\windowspowershell\v1.0> Get-ItemProperty
HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache<br>
<br>
<br>
PSPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache<br>
PSParentPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services<br>
PSChildName : Dnscache<br>
PSDrive : HKLM<br>
PSProvider : Microsoft.PowerShell.Core\Registry<br>
Type : 32<br>
Start : 2<br>
ErrorControl : 1<br>
ImagePath : C:\WINDOWS\system32\svchost.exe -k NetworkService<br>
DisplayName : DNS Client<br>
Group : TDI<br>
DependOnService : {Tcpip}<br>
DependOnGroup : {}<br>
ObjectName : NT AUTHORITY\NetworkService<br>
Description : Resolves and caches Domain Name System (DNS) names
for this computer. If this service is stopped, this computer will
not be able to resolve DNS names and locate Active Directory domain
controllers. If this service is disabled, any services that
explicitly depend on it will fail to start.<br>
<br>
<br>
PS C:\WINDOWS\system32\windowspowershell\v1.0> sc.exe qc dnscache<br>
[SC] QueryServiceConfig SUCCESS<br>
<br>
SERVICE_NAME: dnscache<br>
TYPE : 20 WIN32_SHARE_PROCESS <br>
START_TYPE : 2 AUTO_START<br>
ERROR_CONTROL : 1 NORMAL<br>
BINARY_PATH_NAME : C:\WINDOWS\system32\svchost.exe -k
NetworkService<br>
LOAD_ORDER_GROUP : TDI<br>
TAG : 0<br>
DISPLAY_NAME : DNS Client<br>
DEPENDENCIES : Tcpip<br>
SERVICE_START_NAME : NT AUTHORITY\NetworkService<br>
<br>
<br>
<br>
On 2/06/11 8:50 AM, Storer, Raymond wrote:
<blockquote
cite="mid:03786F597DCEC841AFE52DEC8B9E2FA6099A03B3@EX1.nibco.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]-->
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";
color:black;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle25
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle26
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle27
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle28
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle29
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Scott
and David, I’m not finding any .net call that will produce
the “StartupType” for a service that is already installed.
There is a documented way to do it from a Win32 API; but,
that involves using P/Invoke. See here: <a
moz-do-not-send="true"
href="http://www.leeholmes.com/blog/2009/01/19/powershell-pinvoke-walkthrough/">http://www.leeholmes.com/blog/2009/01/19/powershell-pinvoke-walkthrough/</a>
and here:
<a moz-do-not-send="true"
href="http://pinvoke.net/default.aspx/advapi32/QueryServiceConfig.html">http://pinvoke.net/default.aspx/advapi32/QueryServiceConfig.html</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Ray<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> Scot Kreienkamp
[<a class="moz-txt-link-freetext" href="mailto:SKreien@la-z-boy.com">mailto:SKreien@la-z-boy.com</a>]
<br>
<b>Sent:</b> Wednesday, June 01, 2011 11:03 AM<br>
<b>To:</b> Storer, Raymond; David Baldwin<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> RE: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">This
is what I have so far:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">function
XymonSvcsNET2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$result =
[reflection.Assembly]::LoadWithPartialName("System.ServiceProcess")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$Services =
[System.ServiceProcess.ServiceController]::GetServices()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$COLUMNNAME="Name"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$COLUMNSTATUS="Status"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$COLUMNDESCRIPTION="Description"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
#[Reflection.Assembly]::Load(‘System.ServiceProcess,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a’)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
#get all the services installed on the local machine<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$serviceController =
[System.ServiceProcess.ServiceController]::GetServices()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
"[svcs]"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
"--------------------------------------------------------------------------------------------------------------"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
"{0,-50} {1,-20} {2,-20}" -f `<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$COLUMNNAME, $COLUMNSTATUS, $COLUMNDESCRIPTION<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
"--------------------------------------------------------------------------------------------------------------"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
foreach ($svc in $serviceController) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
"{0,-50} {1,-20} {2,-20}" -f `<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
$svc.Name, $svc.Status, $svc.DisplayName<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">I
did get the formatting figured out finally after about 6
hours. The only piece that I cannot figure out is the
service startup type, if I can get some help on that I think
this is workable.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">I'm
a complete newbie at powershell, so comments/help
appreciated.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);">Scot Kreienkamp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);">Senior Systems Engineer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);"><a moz-do-not-send="true"
href="mailto:skreien@la-z-boy.com">skreien@la-z-boy.com</a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> <a class="moz-txt-link-abbreviated" href="mailto:xymon-bounces@xymon.com">xymon-bounces@xymon.com</a>
[<a class="moz-txt-link-freetext" href="mailto:xymon-bounces@xymon.com">mailto:xymon-bounces@xymon.com</a>]
<b>On Behalf Of </b>Storer, Raymond<br>
<b>Sent:</b> Monday, May 16, 2011 10:38 AM<br>
<b>To:</b> David Baldwin<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> Re: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">David,
you can also use the “Load” method instead as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">[Reflection.Assembly]::Load(‘System.ServiceProcess,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a’)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><br>
Ray<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> David Baldwin
[<a class="moz-txt-link-freetext" href="mailto:David.Baldwin@ausport.gov.au">mailto:David.Baldwin@ausport.gov.au</a>]
<br>
<b>Sent:</b> Monday, May 16, 2011 12:39 AM<br>
<b>To:</b> 'Scot Kreienkamp'; Storer, Raymond<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> RE: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU">Ray,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU">Thanks for the code. I’m a bit wary of using
something with such a version specific path though – is that
seriously a “standard” interface to a .Net DLL that can be
expected to have some degree of persistence?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU">I’m offsite this week, will try to take a look
next week.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU">Thanks, David.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"
lang="EN-AU"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> Scot Kreienkamp
[<a class="moz-txt-link-freetext" href="mailto:SKreien@la-z-boy.com">mailto:SKreien@la-z-boy.com</a>]
<br>
<b>Sent:</b> Saturday, 14 May 2011 5:54 AM<br>
<b>To:</b> Storer, Raymond; David Baldwin<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> RE: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-AU"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Thank
you Raymond… If I knew how to implement it I would.
Hopefully David or Henrik can find the time to experiment
with it.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">I'm
seeing all kinds of problems with the PS client…. If this
keeps up I'll have to remove it. It pegged one of my
servers at 100% for over an hour, stuck on the WMI
yesterday.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);">Scot Kreienkamp<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);">Senior Systems Engineer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:
"Arial","sans-serif"; color: rgb(31,
73, 125);"><a moz-do-not-send="true"
href="mailto:skreien@la-z-boy.com">skreien@la-z-boy.com</a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> Storer, Raymond [<a class="moz-txt-link-freetext" href="mailto:storerr@nibco.com">mailto:storerr@nibco.com</a>]
<br>
<b>Sent:</b> Friday, May 13, 2011 12:58 PM<br>
<b>To:</b> David Baldwin; Scot Kreienkamp<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> RE: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Opps…
I missed the “.” in the [Reflection.Assembly]. Also, you can
pipe it to out-null to avoid any unwanted output. So:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">[Reflection.Assembly]::LoadFile(‘C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727\System.ServiceProcess.dll’)
| out-null<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Ray<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;">From:</span></b><span style="font-size:
10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;"> <a class="moz-txt-link-abbreviated" href="mailto:xymon-bounces@xymon.com">xymon-bounces@xymon.com</a>
[<a class="moz-txt-link-freetext" href="mailto:xymon-bounces@xymon.com">mailto:xymon-bounces@xymon.com</a>]
<b>On Behalf Of </b>Storer, Raymond<br>
<b>Sent:</b> Friday, May 13, 2011 11:40 AM<br>
<b>To:</b> David Baldwin; Scot Kreienkamp<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:xymon@xymon.com">xymon@xymon.com</a><br>
<b>Subject:</b> Re: [Xymon] Windows PS client svcs data
missing<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Scot
and David, if you’d prefer to implement a .net pure call for
services you can try the following:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">#
your path to the file may very<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">[ReflectionAssembly]::LoadFile(‘C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727\System.ServiceProcess.dll’)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">#get
all the services installed on the local machine<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">$serviceController
= [System.ServiceProcess.ServiceController]::GetServices()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">foreach
($svc in $serviceController) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
# should indicate: Stopped, Running, or Paused … others???<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
write-host $svc.Status<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
# the service name<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
write-host $svc.Name<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
# the service display name<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">
write-host $svc.DisplayName<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">Ray<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125);">[snip]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family:
"Arial","sans-serif"; color: gray;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; font-family:
"Times New Roman","serif"; color:
windowtext;"><o:p> </o:p></span></p>
<div class="MsoNormal" style="text-align: center;"
align="center"><span style="font-size: 12pt; font-family:
"Times New Roman","serif"; color:
windowtext;">
<hr align="center" width="100%" size="2">
</span></div>
<p class="MsoNormal"><span style="font-size: 7.5pt; font-family:
"Arial","sans-serif"; color: gray;">CONFIDENTIALITY
NOTICE: This email and any attachments are for the<br>
exclusive and confidential use of the intended recipient. If
you are not<br>
the intended recipient, please do not read, distribute or
take action in<br>
reliance upon this message. If you have received this in
error, please<br>
notify us immediately by return email and promptly delete
this message<br>
and its attachments from your computer system. We do not
waive<br>
attorney-client or work product privilege by the
transmission of this<br>
message.</span><span style="font-size: 12pt; font-family:
"Times New Roman","serif"; color:
windowtext;"><o:p></o:p></span></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family:
"Arial","sans-serif"; color: gray;">This
message is intended only for the individual or entity to
which it is addressed. It may contain privileged,
confidential information which is exempt from disclosure
under applicable laws. If you are not the intended
recipient, please note that you are strictly prohibited from
disseminating or distributing this information (other than
to the intended recipient) or copying this information. If
you have received this communication in error, please notify
us immediately by e-mail or by telephone at the above
number. Thank you.
<o:p></o:p></span></p>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1">CONFIDENTIALITY NOTICE:
This email and any attachments are for the<br>
exclusive and confidential use of the intended recipient. If you
are not<br>
the intended recipient, please do not read, distribute or take
action in<br>
reliance upon this message. If you have received this in error,
please<br>
notify us immediately by return email and promptly delete this
message<br>
and its attachments from your computer system. We do not waive<br>
attorney-client or work product privilege by the transmission of
this<br>
message.<br>
</font>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
David Baldwin - IT Unit
Australian Sports Commission <a class="moz-txt-link-abbreviated" href="http://www.ausport.gov.au">www.ausport.gov.au</a>
Tel 02 62147830 Fax 02 62141830 PO Box 176 Belconnen ACT 2616
<a class="moz-txt-link-abbreviated" href="mailto:david.baldwin@ausport.gov.au">david.baldwin@ausport.gov.au</a> Leverrier Street Bruce ACT 2617
</pre>
<br>
<hr>
Keep up to date with what's happening in Australian sport visit <a href="http://www.ausport.gov.au">www.ausport.gov.au</a>
<br><br>
<font size="-2" face="arial">This message is intended for the addressee named and may contain confidential and privileged information. If you are not the intended recipient please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you receive this message in error, please delete it and notify the sender.</font>
<hr>
</body>
</html>