starter: wmi exchange in a datacenter

Upload: nathan-swift

Post on 14-Oct-2015

171 views

Category:

Documents


1 download

DESCRIPTION

A presentation aid I used while presenting WMI scripting and querying capabilities in an Exchange data center environment. This was used as a beginning conversation to get a Microsoft BPOS-D support team curious about and exploring WMI capabilities in an Exchange data center environment.

TRANSCRIPT

MFCMAPI

WMI Get Active App Pools Results[PS] C:\Windows\system32>$r = get-wmiobject win32_process -filter "name='w3wp.exe'" -computername 048-SN2MMR1-040[PS] C:\Windows\system32>$r | fl commandline

commandline : c:\windows\system32\inetsrv\w3wp.exe -ap "MSExchangePowerShellAppPool" -v "v2.0" -l "webengine4.dll" -a \\.\pipe\iisipmb350a5ab-eb15-43f3-86c6-8d5fbfd0a61c -h "C:\inetpub\temp\apppools\MSExchangePowerShellAppPool\MSExchangePowerShellAppPool.config" -w "" -m 0

commandline : c:\windows\system32\inetsrv\w3wp.exe -ap "MSExchangeSyncAppPool" -v "v2.0" -l "webengine4.dll" -a \\.\pipe\iisipm769572d7-82e8-42ff-a10d-1bd52f94e1f1 -h "C :\inetpub\temp\apppools\MSExchangeSyncAppPool\MSExchangeSyncAppPool.config" -w "" -m 0What is WMI?The basics: WMI is Windows Management Instrument. This is a middle layer Operating System feature that enables a standardized experience for desktop management interfaces. It collects computer management data from a wide variety of sources, including Exchange, SQL, and AD.What it actually does: WMI collects data on the OS, AD, Exchange, SQL, IIS, DNS, HTTP Monitoring, ect for tools to query and make changes. Tools include SCCM, SCOM, Powershell,

Where is WMI Located ?Path: C:\Windows\System32\wbem

Sample usedQuestion: from a workhorse what IIS app pools are running on a remote server, is ews up and running. What app pools are hosted on this server ?WMI Get Active App Pools$r = get-wmiobject win32_process -filter "name='w3wp.exe'" -computername xxxxxxx

$r | fl commandline

Breakdown of Get-WMIOBJECT$r = get-wmiobject -Namespace "Root\Cimv2 -Class win32_process -filter "name='w3wp.exe'" -computername xxxxx

WMI Root ("Root\Cimv2)

WMI ClassName (win32_process)

Query,Filter on WMI String (-filter)

WMI String specifics (name='w3wp.exe)

WMI RootsCommon Roots:

Root\Cimv2 Default Root , Windows OSRoot\HPQ HP Servers WMI, ILO,Disks,Fans

Where can I find the roots for WMI? wmimgmt.msc > can go to properties and security tab to see all roots on server

WMI ClassNamesAn extensive list of WMI class names can be found by running:

Get-WmiObject -Namespace "Root\Cimv2" ListGet-WmiObject -Namespace Root\HPQ List

Common WMI Class Names:-Namespace "Root\Cimv2 Class Win32_Process-Namespace "Root\Cimv2 Class Win32_Service-Namespace Root\HPQ -Class HPSA_DiskDrive

WMI Query | Strings So I have a Root and a Class what's next ?

We need to know what we can query or filter against.

We obtain this by getting a list of the methods and properties of a particular class

Get-WmiObject -Class Win32_process | Get-MemberCommon WMI SearchesWMI Get State of Automatic Services

$r = Get-WmiObject -Class Win32_Service -filter "StartMode='Auto'" -computername xxxxx$r | ft Name,State,exitcode -a

WMI Get Start Mode of Service$f = Get-WmiObject -Class Win32_Service -filter "Name='MSExchangeTransport'" -computername xxxxx, yyyyy, zzzzz$f | ft Name,State,Startmode -a

WMI Get Active App Pools

$r = get-wmiobject win32_process -filter "name='w3wp.exe'" -computername xxxxx$r | fl commandlineWMI errors | Test-servicehealth Failing[PS] C:\Windows\system32>Test-ServiceHealth Couldn't get information about the Exchange services using Windows Management Instrumentation (WMI) due to error: WMI exception occurred on server xxxxxxx.yyyyyy.zzzz.aaaaa.com': Invalid namespace+ CategoryInfo : ReadError: (:) [Test-ServiceHealth], ServiceHealthWmiFailureException+ FullyQualifiedErrorId : 3F67AFB8,Microsoft.Exchange.Monitoring.TestServiceHealth

Test and Repair WMI Errors1. Launch wbemtest.exe. Were looking to see if a connection can be made to the default Root.

A Detailed Test and Diagnosis2. Download and run WMIdiag.vbs to get a more thorough diagnosis

Download From:http://www.microsoft.com/en-us/download/details.aspx?id=7684

Repair WMI3. rebuildwmi.ps1WMI GUIScriptomatic

http://www.microsoft.com/en-us/download/details.aspx?id=12028

WMI Explorer

http://gallery.technet.microsoft.com/scriptcenter/89c759b7-20b4-49e8-98a8-3c8fbdb2dd69

Websiteshttp://blogs.technet.com/b/heyscriptingguy/archive/2009/03/03/how-do-i-find-the-names-of-wmi-classes.aspx

http://technet.microsoft.com/en-us/library/ee692772.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384642(v=vs.85).aspx

http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/