I’ve been playing around a bit more this week with the MSH beta and decided I’d share some of the stuff you can do using the WMI functionality in Monad. To start off here’s some one-liners that can be used to get information from the Exchange 2003 WMI classes. Learning how to do things in monad is a little tricky at the moment other peoples blog’s tend to be the best source of information I worked out the one-liners using a post from Adam Barr’s blog
http://www.proudlyserving.com/archives
/2005/08/monad_and_wmi.html also the following blog was really useful as well as it has a whole bunch of samples that helped when I got stuck. http://mow001.blogspot.com/
Display the SMTP Message Queues
get-wmiobject -class Exchange_SMTPQueue -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object LinkName,MessageCount,Size
Display Mailbox sizes
get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object MailboxDisplayName,TotalItems,Size
Display Users that are logged onto OWA
get-wmiobject -class Exchange_Logon -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername -filter "ClientVersion = 'HTTP' and LoggedOnUserAccount != 'NT AUTHORITY\\SYSTEM'" | select-object LoggedOnUserAccount,MailboxDisplayname
Display all public folder sizes and message counts
get-wmiobject -class Exchange_Publicfolder -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object name,messagecount,totalmessagesize
The last one is a sample of listening to the Exchange_Logon class modification events this one still needs a little bit of tweaking
$objConn = New-Object System.Management.ConnectionOptions
$objconn.Impersonation = [System.Management.ImpersonationLevel]::Impersonate
$objconn.EnablePrivileges = 1
$tspan = New-Object System.TimeSpan(0, 0, 10)
$exmangescope = New-Object System.Management.ManagementScope("\\servername\root\MicrosoftExchangeV2", $objconn);
$query = New-Object System.Management.WqlEventQuery("__InstanceModificationEvent",$tspan, "TargetInstance isa `"Exchange_Logon`" and TargetInstance.ClientVersion = `"HTTP`" and TargetInstance.LoggedOnUserAccount != `"NT AUTHORITY\\SYSTEM`"")
$watcher = New-Object System.Management.ManagementEventWatcher($exmangescope,$query)
$e = $watcher.WaitForNextEvent()
$des = 1
while($des -eq 1){
$e.TargetInstance.LoggedOnUserAccount
$e = $watcher.WaitForNextEvent()
Trap{Break}
}
http://www.proudlyserving.com/archives
/2005/08/monad_and_wmi.html also the following blog was really useful as well as it has a whole bunch of samples that helped when I got stuck. http://mow001.blogspot.com/
Display the SMTP Message Queues
get-wmiobject -class Exchange_SMTPQueue -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object LinkName,MessageCount,Size
Display Mailbox sizes
get-wmiobject -class Exchange_Mailbox -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object MailboxDisplayName,TotalItems,Size
Display Users that are logged onto OWA
get-wmiobject -class Exchange_Logon -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername -filter "ClientVersion = 'HTTP' and LoggedOnUserAccount != 'NT AUTHORITY\\SYSTEM'" | select-object LoggedOnUserAccount,MailboxDisplayname
Display all public folder sizes and message counts
get-wmiobject -class Exchange_Publicfolder -Namespace ROOT\MicrosoftExchangev2 -ComputerName servername | select-object name,messagecount,totalmessagesize
The last one is a sample of listening to the Exchange_Logon class modification events this one still needs a little bit of tweaking
$objConn = New-Object System.Management.ConnectionOptions
$objconn.Impersonation = [System.Management.ImpersonationLevel]::Impersonate
$objconn.EnablePrivileges = 1
$tspan = New-Object System.TimeSpan(0, 0, 10)
$exmangescope = New-Object System.Management.ManagementScope("\\servername\root\MicrosoftExchangeV2", $objconn);
$query = New-Object System.Management.WqlEventQuery("__InstanceModificationEvent",$tspan, "TargetInstance isa `"Exchange_Logon`" and TargetInstance.ClientVersion = `"HTTP`" and TargetInstance.LoggedOnUserAccount != `"NT AUTHORITY\\SYSTEM`"")
$watcher = New-Object System.Management.ManagementEventWatcher($exmangescope,$query)
$e = $watcher.WaitForNextEvent()
$des = 1
while($des -eq 1){
$e.TargetInstance.LoggedOnUserAccount
$e = $watcher.WaitForNextEvent()
Trap{Break}
}