<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathan Medd&#039;s Blog &#187; wmi</title>
	<atom:link href="http://www.jonathanmedd.net/tag/wmi/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jonathanmedd.net</link>
	<description>Scripting. Powershell, VMware, Windows, Active Directory &#38; Exchange. All that kind of stuff.....</description>
	<lastBuildDate>Wed, 01 Feb 2012 13:58:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using PowerShell To Check That Windows Server Services Set To Automatic Have Started</title>
		<link>http://www.jonathanmedd.net/2012/01/using-powershell-to-check-that-windows-server-services-set-to-automatic-have-started.html</link>
		<comments>http://www.jonathanmedd.net/2012/01/using-powershell-to-check-that-windows-server-services-set-to-automatic-have-started.html#comments</comments>
		<pubDate>Wed, 11 Jan 2012 16:18:44 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[windows server 2003]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Windows Server 2008 R2]]></category>
		<category><![CDATA[wmi]]></category>
		<category><![CDATA[Windows Server 2003]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2111</guid>
		<description><![CDATA[Following on from the blog post Testing TCP Port Response from PowerShell  which provided a means to check that servers had fully rebooted after a patching and reboot cycle, I needed to take this one step further and check that all of the Windows Services set to Automatic successfully started after the reboot. This should [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from the blog post <a href="http://www.jonathanmedd.net/2011/12/testing-tcp-port-response-from-powershell.html">Testing TCP Port Response from PowerShell</a>  which provided a means to check that servers had fully rebooted after a patching and reboot cycle, I needed to take this one step further and check that all of the Windows Services set to Automatic successfully started after the reboot.</p>
<p>This should be pretty straightforward since we have a <strong>Get-Service</strong> cmdlet. Unfortunately however, this cmdlet does not return a StartMode parameter, i.e. it&#8217;s not possible to tell whether the Startup Type has been set to Automatic, Manual or Disabled. This is quite a large gap in my opinon &#8211; if you agree with me you can vote to get it included in a future release <a href=" http://connect.microsoft.com/PowerShell/feedback/details/416680/get-service-needs-to-add-a-startuptype-noteproperty-to-its-output">here</a>. Of course with PowerShell there&#8217;s usually another way to achieve the same objective and using <strong>Get-WMIObject</strong> it is possible to find out the Startup Type of the service.</p>
<pre class="brush: powershell;">

Get-WmiObject Win32_Service -ComputerName $ComputerName -Filter &quot;StartMode='Auto' AND State='Stopped' AND Name!='SysmonLog'&quot;
</pre>
<p>Notice that we filter out the Perfmon service (SysmonLog) since it is rarely in a started state.</p>
<p>One other thing to watch out for in this script is that the section</p>
<pre class="brush: powershell;">

catch [System.Exception]
</pre>
<p>which is there to catch any WMI queries that fail, e.g. the server hasn&#8217;t rebooted properly or the correct permissions do not exist to make the WMI query, will not pick up any of these failures. This is because try / catch will only catch terminating errors and the WMI failures are non terminating. We can work around this by setting:</p>
<pre class="brush: powershell;">

$ErrorActionPreference = &quot;Stop&quot;
</pre>
<p>and then back to normal afterwards:</p>
<pre class="brush: powershell;">

$ErrorActionPreference = &quot;Continue&quot;
</pre>
<p>The script accepts pipeline input, so for example you could run it like:</p>
<pre class="brush: powershell;">

Get-Content servers.txt | ./Get-AutomaticServiceState.ps1
</pre>
<p>Here it is:</p>
<pre class="brush: powershell;">

&lt;#
.SYNOPSIS
Retrieves any Windows services set to Automatic and are not running

.DESCRIPTION
Retrieves any Windows services set to Automatic and are not running

.PARAMETER  ComputerName
Name of the computer to test the services for

.EXAMPLE
PS C:\&gt; Get-AutomaticServiceState -ComputerName Server01

.EXAMPLE
PS C:\&gt; Get-Content servers.txt | Get-AutomaticServiceState

.NOTES
Author: Jonathan Medd
Date: 11/01/2012
#&gt;

[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$true,HelpMessage=&quot;Name of the computer to test&quot;,
ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
[Alias('CN','__SERVER','IPAddress','Server')]
[System.String]
$ComputerName
)

process {

try {

# Set ErrorActionPreference to Stop in order to catch non-terminating WMI errors
$ErrorActionPreference = &quot;Stop&quot;

# Query the server via WMI and exclude the Performance Logs and Alerts Service
$WMI = Get-WmiObject Win32_Service -ComputerName $ComputerName -Filter &quot;StartMode='Auto' AND State='Stopped' AND Name!='SysmonLog'&quot;

}

catch [System.Exception]

{
$WMI = “” | Select-Object SystemName,Displayname,StartMode,State
$WMI.SystemName = $ComputerName
$WMI.Displayname = &quot;Unable to connect to server&quot;
$WMI.StartMode = &quot;&quot;
$WMI.State = &quot;&quot;
}

finally {

$ErrorActionPreference = &quot;Continue&quot;

}

if ($WMI){

foreach ($WMIResult in $WMI){

$MYObject = “” | Select-Object ComputerName,ServiceName,StartupMode,State
$MYObject.ComputerName = $WMIResult.SystemName
$MYObject.ServiceName = $WMIResult.Displayname
$MYObject.StartupMode = $WMIResult.StartMode
$MYObject.State = $WMIResult.State
$MYObject
}
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2012/01/using-powershell-to-check-that-windows-server-services-set-to-automatic-have-started.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UK PowerShell User Group December 2011 &#8211; Use the WSMAN cmdlets to retreive WMI information</title>
		<link>http://www.jonathanmedd.net/2011/12/uk-powershell-user-group-december-2011-use-the-wsman-cmdlets-to-retreive-wmi-information.html</link>
		<comments>http://www.jonathanmedd.net/2011/12/uk-powershell-user-group-december-2011-use-the-wsman-cmdlets-to-retreive-wmi-information.html#comments</comments>
		<pubDate>Wed, 14 Dec 2011 12:59:52 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[user group]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2072</guid>
		<description><![CDATA[The UK PowerShell User Group for December 2011 will take place at 19.30 GMT on Thursday December 15t. The topic is &#8216;Use the WSMAN cmdlets to retreive WMI information and see a demo of the new WMI API’s CIM cmdlets in PowerShell v3 CTP 2&#8242;. I&#8217;m looking forward to seeing the new CIM cmdlets from [...]]]></description>
			<content:encoded><![CDATA[<p>The UK PowerShell User Group for December 2011 will take place at 19.30 GMT on Thursday December 15t. The topic is &#8216;Use the WSMAN cmdlets to retreive WMI information and see a demo of the new WMI API’s CIM cmdlets in PowerShell v3 CTP 2&#8242;. I&#8217;m looking forward to seeing the new CIM cmdlets from V3 CTP2 since I haven&#8217;t had chance to play with those yet. <a href="http://richardspowershellblog.wordpress.com/2011/12/04/uk-powershell-groupdecember-2011/">Details from Richard Siddaway&#8217;s blog</a> are below:</p>
<p>&nbsp;</p>
<pre>When: Thursday, Dec 15, 2011 7:30 PM (GMT)

Where: Virtual

*~*~*~*~*~*~*~*~*~*</pre>
<p>Discover how to use the WSMAN cmdlets to retreive WMI information and see a demo of the new WMI API’s CIM cmdlets in PowerShell v3 CTP 2</p>
<p><strong>Notes</strong></p>
<p>Richard Siddaway has invited you to attend an online meeting using Live Meeting.<br />
<strong><a href="https://www.livemeeting.com/cc/usergroups/join?id=PJSH3M&amp;role=attend&amp;pw=gG%2FC-75%28m">Join the meeting.</a></strong><br />
<strong>Audio Information</strong><br />
<strong>Computer Audio</strong><br />
To use computer audio, you need speakers and microphone, or a headset.<br />
<strong>First Time Users:</strong><br />
To save time before the meeting, <a href="http://go.microsoft.com/fwlink/?LinkId=90703">check your system </a>to make sure it is ready to use Microsoft Office Live Meeting.<br />
<strong>Troubleshooting</strong><br />
Unable to join the meeting? Follow these steps:</p>
<ol>
<li>Copy this address and paste it into your web browser:
<p>https://www.livemeeting.com/cc/usergroups/join</li>
<li>Copy and paste the required information:<br />
Meeting ID: PJSH3M<br />
Entry Code: gG/C-75(m<br />
Location: https://www.livemeeting.com/cc/usergroups</li>
</ol>
<p>If you still cannot enter the meeting, <a href="http://r.office.microsoft.com/r/rlidLiveMeeting?p1=12&amp;p2=en_US&amp;p3=LMInfo&amp;p4=support">contact support</a></p>
<p><strong>Notice</strong><br />
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2011/12/uk-powershell-user-group-december-2011-use-the-wsman-cmdlets-to-retreive-wmi-information.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reporting on Windows File Server Shares and NTFS Permissions with PowerShell</title>
		<link>http://www.jonathanmedd.net/2011/12/reporting-on-windows-file-server-shares-and-ntfs-permissions-with-powershell.html</link>
		<comments>http://www.jonathanmedd.net/2011/12/reporting-on-windows-file-server-shares-and-ntfs-permissions-with-powershell.html#comments</comments>
		<pubDate>Thu, 08 Dec 2011 13:48:26 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2031</guid>
		<description><![CDATA[I recently had a requirement to audit the Share and NTFS permissions of a Windows File Server. PowerShell contains the Get-ACL cmdlet which makes retreving the NTFS permissions fairly straightforward, but for the Share permissions it is not so easy, but we can make use of WMI and the Win32_LogicalShareSecuritySetting class. The below forum post [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a requirement to audit the Share and NTFS permissions of a Windows File Server. PowerShell contains the <strong><a href="http://technet.microsoft.com/en-us/library/dd347635.aspx">Get-ACL</a></strong> cmdlet which makes retreving the NTFS permissions fairly straightforward, but for the Share permissions it is not so easy, but we can make use of WMI and the <strong><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394188%28v=vs.85%29.aspx">Win32_LogicalShareSecuritySetting</a></strong> class.</p>
<p>The below forum post details some discussion around using this class to find the Share permissions and unsurprisingly the legendary <a href="http://twitter.com/ShayLevy">Shay Levy</a> provides the solution.</p>
<p><a href="http://groups.google.com/group/powershell-users/browse_thread/thread/43f06ce172e68c38?pli=1" target="_blank">http://groups.google.com/group/powershell-users/browse_thread/thread/43f06ce172e68c38?pli=1</a></p>
<p>The following script makes use of this code and adds some parameters depending on your requirements.</p>
<pre class="brush: powershell;">

&lt;#
.SYNOPSIS
Retrieve report of share permissions

.DESCRIPTION
Retrieve report of share permissions

.PARAMETER  ComputerName
Computer name to retrieve share permissions from

.PARAMETER  Share
Name of the share to retrieve permissions from (optional)

.PARAMETER  OutputFile
Name of the file to output the report to (optional)

.EXAMPLE
PS C:\&gt; Get-SharePermissions.ps1 -ComputerName Server01 -Share Share01 -OutputFile C:\Scripts\SharePermissions.csv

.EXAMPLE
PS C:\&gt; Get-SharePermissions.ps1 -ComputerName Server01

.NOTES
Author: Jonathan Medd
Date: 06/12/2011
Version: 0.1

#&gt;

[CmdletBinding()]
param(

[Parameter(Position=0)]
[System.String]
$ComputerName = '.',

[Parameter(Position=1)]
[System.String]
$Share,

[Parameter(Position=2)]
[System.String]
$OutputFile
)

function Translate-AccessMask($val){
Switch ($val)
{
2032127 {&quot;FullControl&quot;; break}
1179785 {&quot;Read&quot;; break}
1180063 {&quot;Read, Write&quot;; break}
1179817 {&quot;ReadAndExecute&quot;; break}
-1610612736 {&quot;ReadAndExecuteExtended&quot;; break}
1245631 {&quot;ReadAndExecute, Modify, Write&quot;; break}
1180095 {&quot;ReadAndExecute, Write&quot;; break}
268435456 {&quot;FullControl (Sub Only)&quot;; break}
default {$AccessMask = $val; break}
}
}

function Translate-AceType($val){
Switch ($val)
{
0 {&quot;Allow&quot;; break}
1 {&quot;Deny&quot;; break}
2 {&quot;Audit&quot;; break}
}
}

# Create calculated properties
$ShareProperty = @{n=&quot;Share&quot;;e={$ShareName}}
$AccessMask = @{n=&quot;AccessMask&quot;;e={Translate-AccessMask $_.AccessMask}}
$AceType = @{n=&quot;AceType&quot;;e={Translate-AceType $_.AceType}}
$Trustee = @{n=&quot;Trustee&quot;;e={$_.Trustee.Name}}

if ($Share){

$filter=&quot;name='$Share'&quot;

$WMIQuery = Get-WmiObject -Class Win32_LogicalShareSecuritySetting -ComputerName $ComputerName -filter $filter | ForEach-Object {
$ShareName = $_.name
$_.GetSecurityDescriptor().Descriptor.DACL | Select-Object $Shareproperty,$AccessMask,$AceType,$Trustee}
}

else {
$WMIQuery = Get-WmiObject -Class Win32_LogicalShareSecuritySetting -ComputerName $ComputerName | ForEach-Object {
$ShareName = $_.name
$_.GetSecurityDescriptor().Descriptor.DACL | Select-Object $Share,$AccessMask,$AceType,$Trustee }
}

if ($OutputFile){
$WMIQuery | Export-Csv $OutputFile -NoTypeInformation
}

else {
$WMIQuery | Format-Table -AutoSize
}
</pre>
<p>&nbsp;</p>
<p>For NTFS permissions <a href="http://twitter.com/JeffHicks" target="_blank">Jeff Hicks</a> has a very useful post for creating NTFS ACL reports.</p>
<p><a href="http://jdhitsolutions.com/blog/2011/06/creating-acl-reports/" target="_blank">http://jdhitsolutions.com/blog/2011/06/creating-acl-reports/</a></p>
<p>The following is a script based off some of the ideas in that post which you can use for generating a report depending on your requirements.</p>
<pre class="brush: powershell;">

&lt;#
.SYNOPSIS
Retrieve report of NTFS permissions

.DESCRIPTION
Retrieve report of NTFS permissions

.PARAMETER  ComputerName
Computer name to retrieve NTFS permissions from

.PARAMETER  Folder
Name of the NTFS path to retrieve permissions from

.PARAMETER  Recurse
Retrieve permissions from subfolders and files

.PARAMETER  OutputFile
Name of the file to output the report to (optional)

.EXAMPLE
PS C:\&gt; Get-NTFSPermissions.ps1 -ComputerName Server01 -Folder D$\Home -OutputFile C:\Scripts\NTFSPermissions.csv

.EXAMPLE
PS C:\&gt; Get-NTFSPermissions.ps1 -Folder D:\Home -Recurse

.NOTES
Author: Jonathan Medd
Date: 07/12/2011
Version: 0.1

#&gt;

[CmdletBinding()]
param(

[Parameter(Position=0)]
[System.String]
$ComputerName = '.',

[Parameter(Position=1,Mandatory=$true,HelpMessage=&quot;Name of the NTFS path to retrieve permissions from&quot;)]
[System.String]
$Folder,

[Parameter(Position=2)]
[Switch]
$Recurse,

[Parameter(Position=3)]
[System.String]
$OutputFile
)

# Set the Path variable dependent on whether its for a remote machine
if ($ComputerName -eq '.'){
$Path = $Folder
}

else {
$Path = &quot;\\$ComputerName\$Folder&quot;
}

if ($OutputFile){
Get-Childitem $Path -Recurse:$Recurse | ForEach-Object {Get-Acl $_.FullName} | Select-Object @{Name=&quot;Path&quot;;Expression={$_.PSPath.Substring($_.PSPath.IndexOf(&quot;:&quot;)+2) }},@{Name=&quot;Type&quot;;Expression={$_.GetType()}},Owner -ExpandProperty Access | Export-CSV $OutputFile -NoTypeInformation
}

else {
Get-Childitem $Path -Recurse:$Recurse | ForEach-Object {Get-Acl $_.FullName} | Select-Object @{Name=&quot;Path&quot;;Expression={$_.PSPath.Substring($_.PSPath.IndexOf(&quot;:&quot;)+2) }},@{Name=&quot;Type&quot;;Expression={$_.GetType()}},Owner -ExpandProperty Access | Format-Table -AutoSize
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2011/12/reporting-on-windows-file-server-shares-and-ntfs-permissions-with-powershell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with the HPQ WMI Provider to find NIC Information on HP Proliant Servers</title>
		<link>http://www.jonathanmedd.net/2011/11/working-with-the-hpq-wmi-provider-to-find-nic-information-on-hp-proliant-servers.html</link>
		<comments>http://www.jonathanmedd.net/2011/11/working-with-the-hpq-wmi-provider-to-find-nic-information-on-hp-proliant-servers.html#comments</comments>
		<pubDate>Mon, 21 Nov 2011 13:32:38 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[HP]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=2013</guid>
		<description><![CDATA[I recently had a task to query NIC information on a number of HP Proliant servers, this included the connected NIC speed, duplex settings and status of the configured HP Team. I initally looked at the WMI class Win32_NetworkAdapterConfiguration  which contains a lot of info around NIC configuration. Unfortunately, it does not include NIC speed [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a task to query NIC information on a number of HP Proliant servers, this included the connected NIC speed, duplex settings and status of the configured HP Team. I initally looked at the WMI class <strong>Win32_NetworkAdapterConfiguration</strong>  which contains a lot of info around NIC configuration. Unfortunately, it does not include NIC speed or duplex settings.</p>
<p>Looking for alternatives, I discovered a <a href="http://www.peetersonline.nl/index.php/powershell/gather-nic-properties-including-speed-and-duplex/">script from Hugo Peeters</a> which instead queried the registry key <strong>HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}</strong> which looked like it would do the job. However, for some reason this works fine for HP rackmount servers, but blades do not appear to publish NIC info to that registry key so I needed to look for something else.</p>
<p>A colleague pointed me to the <a href="http://h18004.www1.hp.com/products/servers/management/wbem/index.html">HPQ WMI Provider</a>, which I had not seen before and there does not appear to be a lot of published info about either. It can be installed as part of the HP Proliant installation process and adds 800+ classes that can be queried via WMI -  a sample is shown below from the Root\HPQ Namespace:</p>
<p><a href="http://www.jonathanmedd.net/wp-content/uploads/2011/11/HPQWMI.png"><img class="aligncenter size-full wp-image-2014" title="HPQWMI" src="http://www.jonathanmedd.net/wp-content/uploads/2011/11/HPQWMI.png" alt="" width="517" height="687" /></a></p>
<p>In this instance, I was able to use the following classes to obtain the information I needed:</p>
<p><strong>HP_EthernetTeam</strong><br />
<strong>HP_EthernetPort</strong><br />
<strong>HP_WinEthLANEndpoint</strong></p>
<p>There is an absolute wealth of information stored in here, so I would encourage you to check it out if you work with Windows Server on HP systems. The script I put together puts together a basic report of some key NIC info, with the knowledge that there are never more than 4 NICs in a server being queried.</p>
<p>Note that I have used the parameter <strong>-ErrorAction Stop</strong> in the WMI queries, to enforce a terminating error to be generated if the WMI query fails. Without this, the error is non-terminating and does not get caught by the Catch statement.</p>
<pre class="brush: powershell;">

$HP_EthernetTeam = Get-WmiObject -Namespace root\hpq -Class HP_EthernetTeam -ComputerName $ComputerName -ErrorAction Stop
</pre>
<pre class="brush: powershell;">

&lt;#
.SYNOPSIS
Retrieve HP NIC Info from HPQ WMI Namespace

.DESCRIPTION
Retrieve HP NIC Info from HPQ WMI Namespace

.PARAMETER  ServersInputFile
Path to the file containing server names

.PARAMETER  OutputFile
Path to the csv file to output data to

.EXAMPLE
PS C:\&gt; Get-HPNICStatus.ps1 -ServersInputFile C:\Scripts\Servers.txt -OutputFile C:\Scripts\HPNICStatus.csv

#&gt;

[CmdletBinding()]
param(

[Parameter(Position=0,Mandatory=$true,HelpMessage=&quot;Path to the file containing server names&quot;)]
[System.String]
$ServersInputFile,

[Parameter(Position=1,Mandatory=$true,HelpMessage=&quot;Path to the csv file to output data to&quot;)]
[System.String]
$OutputFile
)

$ComputerNames = Get-Content $ServersInputFile

# Allow conversion to MB/sec for NIC speed
$NICSpeedConversionConstant = 1000000

$myCol = @()

foreach ($ComputerName in $ComputerNames){

Write-Host &quot;`n`n&quot;
Write-Host &quot;Querying NIC info on $ComputerName&quot;

# Test for HPQ WMI Namespace and deal with a failure in catch statement
try {

$HP_EthernetTeam = Get-WmiObject -Namespace root\hpq -Class HP_EthernetTeam -ComputerName $ComputerName -ErrorAction Stop
$HP_EthernetPort = Get-WmiObject -Namespace root\hpq -Class HP_EthernetPort -ComputerName $ComputerName -ErrorAction Stop
$HP_WinEthLANEndpoint = Get-WmiObject -Namespace root\hpq -Class HP_WinEthLANEndpoint -ComputerName $ComputerName -ErrorAction Stop

Write-Host &quot;Successful query on $ComputerName&quot;

# Calculate Team Health Status based on WMI query result
switch ($HP_WinEthLANEndpoint.HealthState) {
&quot;0&quot; {$HPTeamStatus = &quot;Unknown&quot;; break}
&quot;5&quot; {$HPTeamStatus = &quot;OK&quot;; break}
&quot;10&quot; {$HPTeamStatus = &quot;Degraded/Warning&quot;; break}
&quot;15&quot; {$HPTeamStatus = &quot;Minor Failure&quot;; break}
&quot;20&quot; {$HPTeamStatus = &quot;Major Failure&quot;; break}
&quot;25&quot; {$HPTeamStatus = &quot;Critical Failure&quot;; break}
&quot;30&quot; {$HPTeamStatus = &quot;Non-recoverable Error&quot;; break}
default {$HPTeamStatus = &quot;Unknown&quot;}
}

# Check Ethernet Port Status
$EthernetPortHealthStateArray = @()

foreach ($EthernetPort in $HP_EthernetPort){

switch ($EthernetPort.HealthState) {
&quot;0&quot; {$EthernetPortHealthState = &quot;Unknown&quot;; break}
&quot;5&quot; {$EthernetPortHealthState = &quot;OK&quot;; break}
&quot;10&quot; {$EthernetPortHealthState = &quot;Degraded/Warning&quot;; break}
&quot;15&quot; {$EthernetPortHealthState = &quot;Minor Failure&quot;; break}
&quot;20&quot; {$EthernetPortHealthState = &quot;Major Failure&quot;; break}
&quot;25&quot; {$EthernetPortHealthState = &quot;Critical Failure&quot;; break}
&quot;30&quot; {$EthernetPortHealthState = &quot;Non-recoverable Error&quot;; break}
default {$EthernetPortHealthState = &quot;Unknown&quot;}
}

$EthernetPortHealthStateObject = &quot;&quot; | Select-Object EthernetPortName,EthernetPortHealthStatus
$EthernetPortHealthStateObject.EthernetPortName = $EthernetPort.Description
$EthernetPortHealthStateObject.EthernetPortHealthStatus = $EthernetPortHealthState
$EthernetPortHealthStateArray += $EthernetPortHealthStateObject

}

$MYObject = “” | Select-Object Servername,HPTeamName,HPTeamStatus,HPTeamSpeed,NIC1Description,NIC1Model,NIC1Speed,NIC1FullDuplex,NIC1HealthState,NIC2Description,NIC2Model,NIC2Speed,NIC2FullDuplex,NIC2HealthState,NIC3Description,NIC3Model,NIC3Speed,NIC3FullDuplex,NIC3HealthState,NIC4Description,NIC4Model,NIC4Speed,NIC4FullDuplex,NIC4HealthState
$MYObject.Servername = $ComputerName
$MYObject.HPTeamName = $HP_EthernetTeam.Description
$MYObject.HPTeamStatus = $HPTeamStatus
$MYObject.HPTeamSpeed = [string]($HP_EthernetTeam.Speed / $NICSpeedConversionConstant) + &quot; MB/sec&quot;
$MYObject.NIC1Description = $HP_EthernetPort[0].Description
$MYObject.NIC1Model = $HP_EthernetPort[0].Caption
$MYObject.NIC1Speed = [string]($HP_EthernetPort[0].Speed / $NICSpeedConversionConstant) + &quot; MB/sec&quot;
$MYObject.NIC1FullDuplex = $HP_EthernetPort[0].FullDuplex
$MYObject.NIC1HealthState = $EthernetPortHealthStateArray[0].EthernetPortHealthStatus
$MYObject.NIC2Description = $HP_EthernetPort[1].Description
$MYObject.NIC2Model = $HP_EthernetPort[1].Caption
$MYObject.NIC2Speed = [string]($HP_EthernetPort[1].Speed / $NICSpeedConversionConstant) + &quot; MB/sec&quot;
$MYObject.NIC2FullDuplex = $HP_EthernetPort[1].FullDuplex
$MYObject.NIC2HealthState = $EthernetPortHealthStateArray[1].EthernetPortHealthStatus
$MYObject.NIC3Description = $HP_EthernetPort[2].Description
$MYObject.NIC3Model = $HP_EthernetPort[2].Caption
$MYObject.NIC3Speed = if ($HP_EthernetPort[2].Speed -ne $null){[string]($HP_EthernetPort[2].Speed / $NICSpeedConversionConstant) + &quot; MB/sec&quot;}
$MYObject.NIC3FullDuplex = $HP_EthernetPort[2].FullDuplex
$MYObject.NIC3HealthState = $EthernetPortHealthStateArray[2].EthernetPortHealthStatus
$MYObject.NIC4Description = $HP_EthernetPort[3].Description
$MYObject.NIC4Model = $HP_EthernetPort[3].Caption
$MYObject.NIC4Speed = if ($HP_EthernetPort[3].Speed -ne $null){[string]($HP_EthernetPort[3].Speed / $NICSpeedConversionConstant) + &quot; MB/sec&quot;}
$MYObject.NIC4FullDuplex = $HP_EthernetPort[3].FullDuplex
$MYObject.NIC4HealthState = $EthernetPortHealthStateArray[3].EthernetPortHealthStatus
$myCol += $MYObject
}

# If WMI query fails
catch {

Write-Host &quot;Unsuccessful query on $ComputerName&quot;

$MYObject = “” | Select-Object Servername,HPTeamName,HPTeamStatus,HPTeamSpeed,NIC1Description,NIC1Model,NIC1Speed,NIC1FullDuplex,NIC1HealthState,NIC2Description,NIC2Model,NIC2Speed,NIC2FullDuplex,NIC2HealthState,NIC3Description,NIC3Model,NIC3Speed,NIC3FullDuplex,NIC3HealthState,NIC4Description,NIC4Model,NIC4Speed,NIC4FullDuplex,NIC4HealthState
$MYObject.Servername = $ComputerName
$MYObject.HPTeamName = &quot;HPQ WMI is not installed or WMI query failed&quot;
$MYObject.HPTeamStatus = &quot;N/A&quot;
$MYObject.HPTeamSpeed = &quot;N/A&quot;
$MYObject.NIC1Description = &quot;N/A&quot;
$MYObject.NIC1Model = &quot;N/A&quot;
$MYObject.NIC1Speed = &quot;N/A&quot;
$MYObject.NIC1FullDuplex = &quot;N/A&quot;
$MYObject.NIC1HealthState = &quot;N/A&quot;
$MYObject.NIC2Description = &quot;N/A&quot;
$MYObject.NIC2Model = &quot;N/A&quot;
$MYObject.NIC2Speed = &quot;N/A&quot;
$MYObject.NIC2FullDuplex = &quot;N/A&quot;
$MYObject.NIC2HealthState = &quot;N/A&quot;
$MYObject.NIC3Description = &quot;N/A&quot;
$MYObject.NIC3Model = &quot;N/A&quot;
$MYObject.NIC3Speed = &quot;N/A&quot;
$MYObject.NIC3FullDuplex = &quot;N/A&quot;
$MYObject.NIC3HealthState = &quot;N/A&quot;
$MYObject.NIC4Description = &quot;N/A&quot;
$MYObject.NIC4Model = &quot;N/A&quot;
$MYObject.NIC4Speed = &quot;N/A&quot;
$MYObject.NIC4FullDuplex = &quot;N/A&quot;
$MYObject.NIC4HealthState = &quot;N/A&quot;
$myCol += $MYObject
}

Clear-Variable HP_EthernetTeam,HP_EthernetPort,HP_WinEthLANEndpoint,HPTeamStatus,EthernetPortHealthStateArray,EthernetPortHealthStateObject,EthernetPortHealthStateArray

}

$myCol | Export-Csv $OutputFile -NoTypeInformation
</pre>
<p>sdf</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2011/11/working-with-the-hpq-wmi-provider-to-find-nic-information-on-hp-proliant-servers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitor Citrix License Usage With PowerShell</title>
		<link>http://www.jonathanmedd.net/2011/01/monitor-citrix-license-usage-with-powershell.html</link>
		<comments>http://www.jonathanmedd.net/2011/01/monitor-citrix-license-usage-with-powershell.html#comments</comments>
		<pubDate>Wed, 05 Jan 2011 13:04:06 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[citrix]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1482</guid>
		<description><![CDATA[WMI in Windows Server is a treasure trove of information and well worth investigating, particularly when needing to run reports against many servers. In addition it is possible for third-parties to make use of WMI and store their own information in there. This is true of a recent requirement I had to monitor Citrix Licensing. [...]]]></description>
			<content:encoded><![CDATA[<p>WMI in Windows Server is a treasure trove of information and well worth investigating, particularly when needing to run reports against many servers. In addition it is possible for third-parties to make use of WMI and store their own information in there. This is true of a recent requirement I had to monitor Citrix Licensing.</p>
<p>Whilst it&#8217;s obviously critical to purchase enough licenses for Citrix that you need, its also important to not have too many lying around not in use, since you&#8217;ll be wasting money.  Given that Citrix Licensing is based on concurrency you may have different usage patterns at the time of day, month or year.</p>
<p>Contained within the WMI Namespace ROOT\CitrixLicensing is a class ﻿﻿Citrix_GT_License_Pool. In this class you can find details for registered licenses and how many are in use. The PowerShell cmdlet <a href="http://technet.microsoft.com/en-us/library/dd315295.aspx" target="_blank">Get-WMIObject</a> can be used to retrieve this information. Once you have it you could save the report into a CSV file, write an entry to an event log or send an email alert.</p>
<p>The below example will generate an email alert when then level of licenses in use goes over 90%. The email will contain basic details of how many licenses are currently in use.</p>
<pre class="brush: powershell;">

﻿&lt;#
.SYNOPSIS
 Report on Citrix License Usage
.DESCRIPTION
 Report on Citrix License Usage
.NOTES
 Authors:Jonathan Medd
.PARAMETER CitrixLicenseServer
 Name of Citrix License Server
.EXAMPLE
 Get-CitrixLicenseUsage -CitrixLicenseServer Server01
#&gt;
param (
 [parameter(Mandatory=$True,HelpMessage='Name of Citrix License Server')]
 $CitrixLicenseServer
 )

# Get Citrix Licensing Info from WMI
$LicensePool = Get-WmiObject -class &quot;Citrix_GT_License_Pool&quot; -Namespace &quot;ROOT\CitrixLicensing&quot; -ComputerName $LicenseServer

# Calculate licenses in use, total number of licenses and percentage currently in use
$InUseNum = ($LicensePool | Measure-Object -Property InUseCount -sum).Sum
$InstalledLicNum = ($LicensePool | Measure-Object -Property Count -sum).Sum
$PercentageNum = [math]::round(($InUseNum/$InstalledLicNum)*100,2)

# Check the usage and send an email if over 90%
if ($PercentageNum -lt 90)
{
}
else
{
Send-MailMessage -To &quot;user@domain.com&quot; -Subject &quot;Citrix License Server Statistics For $CitrixLicenseServer&quot; -Body &quot;The below is the current status of the license server:`n`nInstalled Licences: $InstalledLicNum`n`nLicences In Use: $InUseNum`n`nPercentage: $PercentageNum%&quot; -SmtpServer &quot;smtpserver&quot; -From &quot;user@domain.com&quot;
}
</pre>
<p>sdf</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2011/01/monitor-citrix-license-usage-with-powershell.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Exchange 2003 / WMI / PowerShell article over at http://www.simple-talk.com/</title>
		<link>http://www.jonathanmedd.net/2009/05/exchange-2003-wmi-powershell-article-over-at-httpwwwsimple-talkcom.html</link>
		<comments>http://www.jonathanmedd.net/2009/05/exchange-2003-wmi-powershell-article-over-at-httpwwwsimple-talkcom.html#comments</comments>
		<pubDate>Wed, 13 May 2009 22:06:08 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[exchange 2003]]></category>
		<category><![CDATA[powergui]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=134</guid>
		<description><![CDATA[So I got asked to write an article for the http://www.simple-talk.com/ website, a well known online technical journal and community hub around SQL and .NET technologies. They&#8217;ve recently been branching out into Exchange as well hence they reason they were looking for some Exchange based articles. The article I have written for them is based [...]]]></description>
			<content:encoded><![CDATA[<p>So I got asked to write an article for the <a href="http://www.simple-talk.com/" target="_blank">http://www.simple-talk.com/</a> website, a well known online technical journal and community hub around SQL and .NET technologies. They&#8217;ve recently been branching out into Exchange as well hence they reason they were looking for some Exchange based articles.</p>
<p><a href="http://www.simple-talk.com/exchange/exchange-articles/so-you-thought-powershell-was-only-for-exchange-2007/" target="_blank">The article I have written for them</a> is based around a presentation I have made around some user groups a few times now, i.e. using PowerShell and WMI to manage Exchange 2003. I really enjoyed the process of transferring the content into a written article and hopefully I may get the opportunity to write some more so please check it out.</p>
<p>You can also take advantage of a free Sybex Best Of Exchange 2007 Server ebook by <a href="http://www.simple-talk.com/exchange/exchange-articles/free-exchange-server-ebook/" target="_blank">signing up for their Exchange newsletter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2009/05/exchange-2003-wmi-powershell-article-over-at-httpwwwsimple-talkcom.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slides from MMMUG presentation</title>
		<link>http://www.jonathanmedd.net/2009/02/slides-from-mmmug-presentation.html</link>
		<comments>http://www.jonathanmedd.net/2009/02/slides-from-mmmug-presentation.html#comments</comments>
		<pubDate>Sat, 21 Feb 2009 12:34:00 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[exchange 2003]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[user group]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://jonathanmedd.wordpress.com/2009/02/21/slides-from-mmmug-presentation/</guid>
		<description><![CDATA[As promised to those who attended the MMMUG on Wednesday night my slides from that evening are available on my SkyDrive. Enjoy.]]></description>
			<content:encoded><![CDATA[<p>As promised to those who attended the <a href="http://www.mmmug.co.uk/">MMMUG</a> on Wednesday night my slides from that evening are available on my <a href="http://cid-bad8363d570d175b.skydrive.live.com/browse.aspx/.Public">SkyDrive</a>.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2009/02/slides-from-mmmug-presentation.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

