<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6646412165224764562</id><updated>2011-11-28T01:36:34.996+02:00</updated><category term='users'/><category term='calendar'/><category term='rules'/><category term='cleanup'/><category term='smtp'/><category term='web'/><category term='mailbox'/><category term='ping'/><category term='remote'/><category term='info'/><category term='export'/><category term='template'/><category term='general'/><category term='quest'/><category term='site'/><category term='local groups'/><category term='prf'/><category term='windows forms'/><category term='transport rules'/><category term='powershell'/><category term='perfmon'/><category term='tips'/><category term='html'/><category term='event logs'/><category term='script'/><category term='hub transport'/><category term='folders'/><category term='roundtrip'/><category term='wmi'/><category term='defrag'/><category term='exchange'/><category term='script; audit'/><category term='.NET'/><title type='text'>Powershell Needful Things</title><subtitle type='html'>“Any sufficiently advanced technology is indistinguishable from magic." - Dr. Carl Sagan</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-7256546889676407480</id><published>2010-08-04T17:12:00.002+02:00</published><updated>2010-08-04T17:15:30.211+02:00</updated><title type='text'>Check free space on volume mount points</title><content type='html'>Wow! It’s been a while since I have posted any scripts! This is mainly due to the fact that I am rather busy at work, and also working hard at completing my MCITP.&lt;br /&gt;
&lt;br /&gt;
A while back a client of mine, asked if there was an easy way to use one computer to check the free space of mount points. This was a real problem for them, as the administrators would come in every morning and manually logon to each server, and use disk management to check the free space.&lt;br /&gt;
&lt;br /&gt;
I was certain that there had to be a WMI object for mount points, so after a little digging, I came up with the following script:&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
 
function get-mountpoints {
$volumes = Get-WmiObject -computer $server win32_volume | Where-object {$_.DriveLetter -eq $null}
$volumes | Select SystemName, Label, $TotalGB, $FreeGB, $FreePerc | Format-Table -AutoSize
}
 
$servers = (Get-Content .\servers.txt)
 
foreach ($server in $servers){
get-mountpoints
}
&lt;/pre&gt;The script is written to collect server names from a text file, but you could use any other method to supply you server names.&lt;br /&gt;
&lt;br /&gt;
Hope this helps someone else!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-7256546889676407480?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/7256546889676407480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/08/wow-its-been-while-since-i-have-posted.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7256546889676407480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7256546889676407480'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/08/wow-its-been-while-since-i-have-posted.html' title='Check free space on volume mount points'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1301761389723833325</id><published>2010-05-31T09:24:00.001+02:00</published><updated>2010-05-31T09:28:36.958+02:00</updated><title type='text'>Find and delete duplicate Outlook Contacts</title><content type='html'>I have been fairly busy at work with little or no time to write. I did however manage to write a neat script on Friday which I thought I had to share.&lt;br /&gt;
&lt;br /&gt;
My Nokia decided last week that it felt the need to duplicate all my Outlook contacts after I changed something on the ActiveSync profile. Now, normally this is not a big deal, as you can simply sort the contact items by creation date, and delete the duplicates, that is unless you mess around with them, and recreate them all from scratch. (insert curse word here)&lt;br /&gt;
&lt;br /&gt;
I took one look at this problem and thought that it would be far too easy to just delete them manually. I decided to write a script to do the work for me. I have been playing a lot with the Outlook COM object lately so I already had most of the code to get this done quickly.&lt;br /&gt;
&lt;br /&gt;
The script will collect all your contacts, and do a unique sort on the FullName. It then creates a temp folder under your default contacts folder, and moves the unique contacts (remember sorted by FullName only), to the temp folder. &lt;br /&gt;
&lt;br /&gt;
It then dumps all the duplicates in the default contacts to a CSV and deletes them from the contacts.&lt;br /&gt;
&lt;br /&gt;
At this point I stopped the script, as it made sense to check the CSV and the temp folder, and move your contacts back manually if you are happy with the results.&lt;br /&gt;
&lt;br /&gt;
As usual, be very careful with this one. Automatic deletes always have the potential to end in tears. Make a backup of all your contacts before you start with the script.&lt;br /&gt;
&lt;br /&gt;
I hope this script can help you.&lt;br /&gt;
&lt;br /&gt;
You can download the script from here:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" style="width:98px;height:115px;padding:0;background-color:#fcfcfc;" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedicon.aspx/.Public/clean-contacts.ps1"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1301761389723833325?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1301761389723833325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/05/find-and-delete-duplicate-outlook.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1301761389723833325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1301761389723833325'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/05/find-and-delete-duplicate-outlook.html' title='Find and delete duplicate Outlook Contacts'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1143912033903115698</id><published>2010-03-02T13:56:00.013+02:00</published><updated>2010-05-03T08:53:19.676+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='script; audit'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Determine the source site of Outlook clients on Exchange server</title><content type='html'>We have been toying with the idea of centralising our Exchange environment for a while now, and as part of this project, we needed to audit our Outlook clients, to determine which source site they were connecting from.&lt;br /&gt;
&lt;br /&gt;
I was tasked with this, and was able to quickly gather this information, from both the Exchange 2003 and the 2007 environment, without too much hassle.&lt;br /&gt;
&lt;br /&gt;
For Exchange 2007 simply use get-logonstatistics and select the information that you need. I added some additional spice, which exports each server to a separate CSV file.&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;foreach ($server in get-mailboxserver){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
Get-LogonStatistics -server $server | select UserName, ClientIPAddress | sort UserName -Unique | Export-Csv $filename
}
&lt;/pre&gt;Exchange 2003 is very similar, but as you can probably guess by now, you need to use WMI.&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;foreach ($server in (Get-ExchangeServer | Where {$_.IsExchange2007OrLater -eq $false})){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Logon -Computer $server | select MailboxDisplayName, ClientIP | sort MailboxDisplayName -Unique | Export-Csv $filename
}
&lt;/pre&gt;My job done, I sent the CSV files of the project managers, only to find out that they thought it would be nice, to see exactly which site each IP address belonged to.&lt;br /&gt;
&lt;br /&gt;
This proved to be a little more tricky, but after a few minutes of probing the Interwebs, I found a post where Shay uses nltest to get the site information for a computer.&lt;br /&gt;
&lt;br /&gt;
I assimilated this into my script with a little DNS lookup to find the host name and came up with a function which will retrieve the site information for each IP address on the fly and add that to the CSV file.&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;function Get-ComputerSite ($ip){
Write-Host "Current IP:" $ip
$site = $null
$computer = [System.Net.Dns]::gethostentry($ip) 
$site = nltest /server:$($computer.hostname) /dsgetsite
Return $site[0]
}

$ADSiteWMI = @{Name="ADSite";expression={Get-ComputerSite $($_.ClientIP)}}
$ADSite = @{Name="ADSite";expression={Get-ComputerSite $($_.ClientIPAddress)}}

foreach ($server in get-mailboxserver){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
$LogonStats = Get-LogonStatistics -server $server | sort UserName -Unique 
$LogonStats | select UserName, ClientIPAddress, $ADSite | Export-Csv $filename 
}

foreach ($server in (Get-ExchangeServer | Where {$_.IsExchange2007OrLater -eq $false})){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
$LogonStats = Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Logon -Computer $server | sort MailboxDisplayName -Unique
$LogonStats | select MailboxDisplayName, ClientIP, $ADSiteWMI | Export-Csv $filename
&lt;/pre&gt;This does take some time to complete on servers with many connections, but it gets the results required. I have already noticed a few issues, and the script can do with a little more refinement.&lt;br /&gt;
&lt;br /&gt;
I will post these updates as soon as I get round to adding them. For now, I hope this script can help someone else with a similar problem.&lt;br /&gt;
&lt;br /&gt;
The complete script can be downloaded from here:&lt;br /&gt;
&lt;iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" style="width:98px;height:115px;padding:0;background-color:#fcfcfc;" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedicon.aspx/.Public/get-clientIPaddress.ps1"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1143912033903115698?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1143912033903115698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/03/determine-source-site-of-outlook.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1143912033903115698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1143912033903115698'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/03/determine-source-site-of-outlook.html' title='Determine the source site of Outlook clients on Exchange server'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1152111647664095347</id><published>2010-02-12T12:38:00.011+02:00</published><updated>2010-02-18T07:39:04.473+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rules'/><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='hub transport'/><category scheme='http://www.blogger.com/atom/ns#' term='transport rules'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Using SCL to prevent messages from going to Junk Mail</title><content type='html'>In our environment, we have a number of email addresses which are managed by automated programs and systems and even some home grown applications.&lt;br /&gt;
&lt;br /&gt;
Most of these systems use POP3 to connect to the mailboxes and download incoming email. Obviously POP3 does not give you access to subfolders like “Junk Mail”. It has come to our attention recently, that the Junk email rule has been flagging valid client messages as Junk Mail, and sending these messages to the Junk Mail folder. The result is that these instructions / client information never make it to the back office workflow systems.&lt;br /&gt;
&lt;br /&gt;
To prevent this from happening, you first need to understand SCL or Spam Confidence Level.&lt;br /&gt;
&lt;br /&gt;
The SCL, in a nutshell is basically a score based on a number of criteria, which determine how likely a message is to contain spam. The higher the score (maximum 9) the more confident Outlook is that the message is spam.&lt;br /&gt;
&lt;br /&gt;
An awesome way to view the SCL for individual messages is to install a custom form, which displays an additional column with this information. More information about that here: http://msexchangeteam.com/archive/2004/05/26/142607.aspx&lt;br /&gt;
&lt;br /&gt;
After installing the form, I needed to start sending some spam to myself. This would establish the same message is either blocked or cleared by the Transport Rule. I grabbed an obvious spam message from my Gmail account and turned it into a Powershell spambot:&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;pre class="brush: powershell"&gt;$messageParameters = @{

Subject = "Vicodin ES (Hydrocodone) 650mg x 30 pills $209 -VISA- tbrkl rqg" Body = " -== The Best Painkillers available ==- Buy Hydrocodone, Vicodin ES, Codeine, Phentermin, Norco, Valiuml, Xanaxl Online You pay &amp;amp; we ship, Absolute NO question asked No PrescriptionNeeded (No doctor approval needed!) 100% deliver your order to your house We have been in business since 1998 This is a rare bargain online to obtain these UNIQUE products. No prior order needed. Limited supply of these hard to get pills, so hurry! "

From = "spambot9k@spam-the-planet.com"
To = "spambots@spam-the-planet.com"&amp;nbsp;
Bcc = "jean.louw@domain.com"&amp;nbsp;
SmtpServer = "1.1.1.1"&amp;nbsp;
}
Send-MailMessage @messageParameters –BodyAsHtml

&lt;/pre&gt;&lt;br /&gt;
Confirmed! My spam message was being trapped by the Junk Mail rule with SCL 9 and moved to the Junk Mail folder.&lt;br /&gt;
&lt;br /&gt;
OK, next we needed to create the Transport Rule. Now, if you are new to Powershell / Exchange I would suggest creating the rule in the GUI, as the interface / wizard used in that process is similar to the Outlook rules wizard.&lt;br /&gt;
&lt;br /&gt;
Once you have the rule created it is very easy to add additional addresses using Powershell. More about that later. For the purposes of this post, I will however create the rule using the shell.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;pre class="brush: powershell"&gt;$condition = Get-TransportRulePredicate SentTo&amp;nbsp;
$condition.Addresses = @((Get-Mailbox "*jean.louw*"))&amp;nbsp;
$action = Get-TransportRuleAction SetSCl $action.SclValue = "-1"&amp;nbsp;
$warning = "WARNING: Adding mailboxes to this rule will prevent the Junk Mail rule from detecting possible spam."&amp;nbsp;

New-TransportRule -name "Set SCL level to -1" -Conditions @($condition) -Action @($action) -Comments $warning
&lt;/pre&gt;&lt;br /&gt;
This script will create the rule to set the SCL for all messages to matching addresses to -1. You can replace "(Get-Mailbox "*jean.louw*")" with any expression or command, which will give you the mailboxes you need to add to the rule.&lt;br /&gt;
&lt;br /&gt;
Now that we have the rule in place, we need to confirm that it is working. Yet again, I sent a control “spam” message ala spambot9000.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;This time the message SCL was -1, as we predicted, and the message was not moved to Junk Mail as before.&lt;br /&gt;
&lt;br /&gt;
In future, should you need to add additional email addresses to your rule, you can use the following:&lt;/div&gt;&lt;pre class="brush: powershell"&gt;$condition = Get-TransportRulePredicate SentTo&amp;nbsp;
$condition.Addresses = @((Get-Mailbox "*system*"))&amp;nbsp;
$condition.Addresses += @((Get-Mailbox "*louw, jean*"))&amp;nbsp;
Set-TransportRule "Set SCL level to -1" -Conditions @($condition)
&lt;/pre&gt;&lt;br /&gt;
Remember that you have to add all of your address searches, each time, as the conditions are overwritten by set-transportrule. This is a really easy way to get around the problem of false positives in mailboxes where humans don't manage mailboxes, and are unable to notice that valid emails are being sent to Junk Mail.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1152111647664095347?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1152111647664095347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/02/using-scl-to-prevent-messages-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1152111647664095347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1152111647664095347'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2010/02/using-scl-to-prevent-messages-from.html' title='Using SCL to prevent messages from going to Junk Mail'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-532950117016835741</id><published>2009-11-18T08:42:00.002+02:00</published><updated>2009-11-18T08:46:09.971+02:00</updated><title type='text'>Find specific group membership</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;One of our administrators needed to present a report, which could show a list of users, and whether or not, they belonged to a specific group or groups, which control their browsing privileges.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Doing this manually was an immense task, but obviously using Powershell, it becomes a job you can do while reading your news paper. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The script example is a very basic solution, but it gets the job done. It uses the Quest Active Roles commands in an expression, which displays yet again, the magic of Powershell and how much time it could save you as an administrator, when working with thousands of items this way.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Although this is not groundbreaking stuff, I share this in the hope that it could save someone else some time&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;$websense = @{Name="WebSense Group";expression={Get-QADMemberOf -sizelimit 0 -identity $_ | where {($_.Name -like "*Websense*") -or ($_.Name -match "Global Browsing")}}}
(gc .\users.txt) | foreach {Get-QADUser -sizelimit 0 -identity $_} | select Name, $websense | Export-Csv .\websense.csv
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-532950117016835741?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/532950117016835741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/find-specific-group-membership.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/532950117016835741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/532950117016835741'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/find-specific-group-membership.html' title='Find specific group membership'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-495156147515429126</id><published>2009-11-13T14:35:00.023+02:00</published><updated>2009-11-13T15:18:48.277+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='script; audit'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>Exchange 2007 Audit Script - Version 3</title><content type='html'>&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_GxzZCShiNW8/Sv1Y4DGES7I/AAAAAAAAALc/J0XeOjrONtc/s1600-h/rampage.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;br /&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I have updated the Exchange 2007 audit script yet again!&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_GxzZCShiNW8/Sv1Y4DGES7I/AAAAAAAAALc/J0XeOjrONtc/s1600-h/rampage.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_GxzZCShiNW8/Sv1Y4DGES7I/AAAAAAAAALc/J0XeOjrONtc/s320/rampage.png" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;Included in this update are two MAJOR changes, firstly, the script uses and publishes information using the new HTML format, as created by &lt;a href="http://www.virtu-al.net/"&gt;Virtu-Al&lt;/a&gt;.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This script, and the functions which create its HTML output are far more efficient and literally cut the number of lines in the script down by half. Not only is the code leaner, but it is also infinitely more legible, and adding new tests to the current script is a breeze. This version of the HTML output is also compatible with multiple browsers, including Mozilla and Chrome.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Secondly, the script will now detect pipeline input. You can still use a server list as a parameter to the script, but now, you can also pipe content to the script. This content can include your server list, or output from Exchange commands such as get-transportserver or get-mailboxserver etc. Be careful though, because commands like get-exchangeserver could include Exchange 2003 servers.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;If no server list is specified or piped, the script will still get all Exchange 2007 servers.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;As another minor addition, I have added an additional test (Test-OutlookWebServices) to the CAS servers.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;As always, your comments and feedback is always welcome.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;The script can be downloaded from here:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/test-exchange2k7_V3.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-495156147515429126?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/495156147515429126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html#comment-form' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/495156147515429126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/495156147515429126'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html' title='Exchange 2007 Audit Script - Version 3'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_GxzZCShiNW8/Sv1Y4DGES7I/AAAAAAAAALc/J0XeOjrONtc/s72-c/rampage.png' height='72' width='72'/><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-4214905753935574299</id><published>2009-11-05T14:44:00.004+02:00</published><updated>2009-11-13T14:52:13.332+02:00</updated><title type='text'>Updated: Exchange 2007 audit script (Version 2)</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I have finally been able to complete the updates to my Exchange 2007 audit script. The script has some enhancements which includes suggestions and comments from some readers.&lt;br /&gt;
&lt;br /&gt;
The new script includes a few checks against CAS servers, which I feel have been neglected in the past. These checks include &lt;i&gt;test-owaconnectivity&lt;/i&gt; and &lt;i&gt;test-activesyncconnectivity&lt;/i&gt;. These two commands need some additional work to enable. To test if these command will work, you can run both test-owaconnectivity and test-activesyncconnectivity with the –ClientAccessServer switch. Additional information will be available in the console if the commands are unable to run.&lt;br /&gt;
&lt;br /&gt;
I have been meaning to update the HTML format, as designed and used by &lt;a href="http://www.virtu-al.net/"&gt;Virtu-Al&lt;/a&gt;, but I have been unable to find the time. This is definitely high on the priority list, as the new format is supported by multiple browsers, and cuts down the number of lines of code significantly. I really wanted to include the new HTML in this release, but it would have delayed the release by weeks.&lt;br /&gt;
&lt;br /&gt;
Here is a complete list of changes:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;- You have the option to specify a list of servers to audit, if you don’t, the script will use get-exchangeserver to find servers to audit.&lt;br /&gt;
&amp;nbsp;- Changed disk space to values to gigabyte.&lt;br /&gt;
&amp;nbsp;- Added white space to mailbox store report. ( This is done with dotnet, and has been optimised to be really quick)&lt;br /&gt;
&amp;nbsp;- Added MAPI connectivity test to mailbox server report.&lt;br /&gt;
&amp;nbsp;- Added OWA connectivity report for CAS servers.&lt;br /&gt;
&amp;nbsp;- Added ActiveSync connectivity report for CAS servers.&lt;br /&gt;
&amp;nbsp;- Cleaned up some variable names.&lt;br /&gt;
&lt;br /&gt;
I will release a newer version soon, which will include a few additional checks, and will also use the latest HTML code.&lt;br /&gt;
&lt;br /&gt;
Your comments and suggestions are always welcome.&lt;br /&gt;
&lt;br /&gt;
The script can be downloaded from here:&lt;br /&gt;
&lt;br /&gt;
This script has been replaced by a later version, please check the following link, or download the updated version below:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html"&gt;http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/test-exchange2k7_V3.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-4214905753935574299?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/4214905753935574299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/updated-exchange-2007-audit-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4214905753935574299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4214905753935574299'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/updated-exchange-2007-audit-script.html' title='Updated: Exchange 2007 audit script (Version 2)'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-4615276457351835337</id><published>2009-11-04T14:32:00.016+02:00</published><updated>2009-11-04T22:17:31.987+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>Exchange summary reports</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Taking a cue from a post on the &lt;a href="http://blogs.msdn.com/powershell/archive/2009/10/30/sending-automated-emails-with-send-mailmessage-convertto-html-and-the-powershellpack-s-taskscheduler-module.aspx"&gt;Windows Powershell Blog, by James Brundage&lt;/a&gt;, I decided to create a few notifications for my Exchange environment.&lt;br /&gt;
&lt;br /&gt;
These little “scriptlets” will pop off a notification message in HTML format with a summary of information gathered by each.&lt;br /&gt;
&lt;br /&gt;
The information is not server specific, as I tried to limit the number of instances required. And the content is very basic, but it gets the job done.&lt;br /&gt;
&lt;br /&gt;
You can refer to James’ post above for more information on how to automatically schedule these to run.&lt;br /&gt;
&lt;br /&gt;
You can copy the scripts by hovering over the code block and selecting “view source”&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;Mailbox database summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//Mailbox Database Reports
$messageParameters = @{
    Subject = "Exchange 2007 Database Report - $((Get-Date).ToShortDateString())"
    Body =  Get-MailboxDatabase -status | 
   Select-Object Server, Name, Mounted, LastFullBackup | 
   Sort-Object Server, Name |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;b&gt;Exchange 2007 queue summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//Exchange 2007 Queue Report
$messageParameters = @{
    Subject = "Exchange 2007 Queue Report - $((Get-Date).ToShortDateString())"
    Body =  Get-TransportServer |
   ForEach-Object { Get-Queue -Server $_ | 
   Select-Object NextHopDomain, MessageCount, Status} | 
   Sort-Object NextHopDomain |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;b&gt;Exchange 2003 queue summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//Exchange 2003 Queue Report
$messageParameters = @{
    Subject = "Exchange 2003 Queue Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer | 
   Where-Object {$_.IsExchange2007OrLater -eq $False} |
   ForEach-Object {
   Get-WmiObject -class exchange_smtpqueue -namespace ROOT\MicrosoftExchangev2 -computername $_ | 
   Where-Object -FilterScript {$_.MessageCount -gt 0} |  
   Select-Object VirtualMachine, QueueName, MessageCount, Size} |
   Sort-Object VirtualMachine |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;b&gt;Exchange 2007 MAPI connectivity summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//MAPI Connectivity Report
$messageParameters = @{
    Subject = "MAPI Connectivity Report - $((Get-Date).ToShortDateString())"
    Body =  Get-MailboxServer |
   Where-Object {(get-mailboxdatabase -Server $_ ).count -gt '0'} |
   ForEach-Object { Test-MAPIConnectivity -Server $_ |
   Select-Object Server, Database, Result, @{Name="Latency(MS)";expression={(([TimeSpan] $_.Latency).TotalMilliSeconds)}}, Error} |
   Sort-Object Server, Database |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;b&gt;Exchange server disk summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//Disk Space Reports
$messageParameters = @{
    Subject = "Exchange Disk Space Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer |
   ForEach-Object { Get-WmiObject -computer $_ Win32_LogicalDisk} | 
   Where-Object {$_.DriveType -eq 3} |
   Select-Object SystemName, DeviceID, VolumeName, @{Name="Size(GB)";expression={[math]::round(($_.Size / 1073741824))}}, @{Name="Free(GB)";expression={[math]::round(($_.FreeSpace / 1073741824))}}, @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Size / 1073741824)) * 100),0)}} | 
   Sort-Object SystemName, DeviceID |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;b&gt;Exhcange services summary:&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#//Exchange Services Report
$messageParameters = @{
    Subject = "Exchange Services Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer | 
   ForEach-Object {
   Get-WmiObject -computername $_ -query "select * from win32_service where Name like 'MSExchange%' or Name like 'IIS%' or Name like 'SMTP%' or Name like 'POP%' or Name like 'W3SVC%'" | 
   Select-Object SystemName, DisplayName, StartMode, State} |
   Sort-Object SystemName, DisplayName |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-4615276457351835337?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/4615276457351835337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/taking-cue-from-post-on-windows.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4615276457351835337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4615276457351835337'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/taking-cue-from-post-on-windows.html' title='Exchange summary reports'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-7222807767749338103</id><published>2009-11-03T21:30:00.005+02:00</published><updated>2009-11-04T22:16:50.191+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='info'/><category scheme='http://www.blogger.com/atom/ns#' term='template'/><category scheme='http://www.blogger.com/atom/ns#' term='general'/><category scheme='http://www.blogger.com/atom/ns#' term='site'/><title type='text'>New Look</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you are a regular visitor, you may have noticed that the site looks a little different.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I looked at the site during last week and decided that I had enough of the standard old blogger template. It was really boring, and half the blogger sites out there use the same template.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I spent most of Friday getting the new look ready, and I am pretty sure I have it all working now. I have added some RSS feeds and a Feedburner email subscription page.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I think the new look is cleaner and a little more unique, and&amp;nbsp;I really hope you like it too.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Your comments and suggestions are always welcome.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-7222807767749338103?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/7222807767749338103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/new-look.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7222807767749338103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7222807767749338103'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/11/new-look.html' title='New Look'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-5512995990209356243</id><published>2009-10-30T10:39:00.001+02:00</published><updated>2009-11-04T22:16:20.188+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='perfmon'/><title type='text'>View Performance data in a web browser</title><content type='html'>&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This is a little trick, which I have been meaning to share for a while. It is a very simple way to view performance data for your server, using a web browser. Now I am sure that it’s not news to everyone, but for those of you who see this for the first time, I am sure you’ll be able to use this in your environment.&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
Because I work primarily with Exchange server, I will be using some Exchange performance data for this post. However, you can use any performance counters you require, according to my knowledge they all work the same way.&lt;br /&gt;
&lt;br /&gt;
To setup a basic html page with some performance data, open performance monitor, and add a counter from a remote server. I my case I have selected the % Processor Time. Once the graph starts populating with data, right-click anywhere on the graph and select “Save As”. Save the html file, either to your web server, or anywhere on your disk.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://3.bp.blogspot.com/_GxzZCShiNW8/SumCOgpN_II/AAAAAAAAAKs/eZspLUP5x_k/s1600-h/2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_GxzZCShiNW8/SumCOgpN_II/AAAAAAAAAKs/eZspLUP5x_k/s200/2.png" /&gt;&lt;/a&gt;If you open the file from the disk, you have to manually start the logging again, I have noticed that if the page is loaded from a web server this is not required.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
Microsoft included a very nice performance template in the Exchange 2007 Toolbox. I think we’ll start there, and open a performance counter with some pre-loaded information. You can access the performance data from the Exchange Management Console. Click the Toolbox and select Performance Monitor.&lt;br /&gt;
&lt;br /&gt;
You can now save this data to an html document as before. There is one catch though, the performance data saved from this console points to the local machine. You have to open the html document in a text editor, and do a find and replace on the following string VALUE="\ with VALUE="\\MACHINENAME\ where MACHINENAME is your server name.&lt;br /&gt;
&lt;br /&gt;
Now you should be able to load this html document from any computer or web server and have the selected performance data available.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-5512995990209356243?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/5512995990209356243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/view-performance-data-in-web-browser.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/5512995990209356243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/5512995990209356243'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/view-performance-data-in-web-browser.html' title='View Performance data in a web browser'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_GxzZCShiNW8/SumCOgpN_II/AAAAAAAAAKs/eZspLUP5x_k/s72-c/2.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1931003273247233634</id><published>2009-10-28T08:03:00.011+02:00</published><updated>2009-10-28T12:16:14.696+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='prf'/><category scheme='http://www.blogger.com/atom/ns#' term='export'/><category scheme='http://www.blogger.com/atom/ns#' term='calendar'/><category scheme='http://www.blogger.com/atom/ns#' term='folders'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Bulk export calendars from Exchange mailboxes</title><content type='html'>&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;a href="http://1.bp.blogspot.com/_GxzZCShiNW8/SudCs0KoBKI/AAAAAAAAAH8/kQFJyybCejk/s1600-h/2009-10-27+01-47-19+PM.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_GxzZCShiNW8/SudCs0KoBKI/AAAAAAAAAH8/kQFJyybCejk/s320/2009-10-27+01-47-19+PM.jpg" vr="true" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;I have never really had the need for a script like this, so when our catering manager at the office logged a support call, requesting an export of all calendars for all of our meeting rooms, I had to investigate the possibilities. He basically needed this information in order to determine how busy the individual meeting rooms were during the last year.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;Following a quick, unsuccessful, Internet probing for tools or scripts that could do this, my initial feeling was to say “No sorry, can’t be done, or if we do it, it was going to be a manual task.”&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;A manual task, which involves, granting access to the room mailbox, logging onto the mailbox using Outlook, and exporting the calendar data to Excel. Sounds easy, but doing that a hundred times is very unproductive and torturous to say the least.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;I decided to attempt to script it, and the result is something I am both proud of and ashamed of at the same time, as I am convinced there must be a better way.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;It’s a very rough method, which involves the following process:&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;Get a list of rooms from a text file (as it was emailed to me). You could use get-mailbox instead.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;Add-mailbox permission to the current user&lt;/span&gt; &lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;Create an Outlook profile&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;Logon to the profile&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;Export the Calendar to CSV&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: small;"&gt;Remove-MailboxPermission&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;I could automate most of the above, but creating new profiles on demand is something I’ve never had to do, and frankly, I had no idea how to get around this problem. After speaking to some of the developers at work, who promised me some dotnet code which could do it (which I am still waiting for might I add :)), I decided to use PRF files.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;I have used PRF files very successfully in the past, on Terminal server deployments to automatically setup Outlook profiles. I downloaded the &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=4bb7cb10-a6e5-4334-8925-3bcf308cfbaf&amp;amp;displaylang=en"&gt;ORK&lt;/a&gt; and created a PRF which I used as a template for the script. The blank PRF is attached to this post to save you the time and effort of using ORK.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;The script finds and replaces the UserName and HomeServer in the PRF, although any Exchange server should resolve you to your mailbox server. It then creates a PRF and starts Outlook with the /importPRF switch. Some extra information, for anyone wanting to actually deploy or use the PRF file; the %HomeServer% variable in the PRF does not work the same way %UserName% works, if you want use the PRF, you need to specify one of your mailbox servers instead.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;While Outlook is open on that profile, the script attaches to Outlook using a COM object and downloads the calendar for the specified date.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;The calendar fields can be customised to suit your needs. In my case we simply needed the Start and End date, the duration, and the Organizer.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;The export data is saved and the PRF is removed, sadly the swarm of profiles will remain, and you have to manually remove them. You could remove them from HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles but I have not added that to the script.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;I hope this can help you, if you ever get a freaky request like this.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;The script and the PRF template can be downloaded from here:&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/export-calendar.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/calexp.PRF" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1931003273247233634?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1931003273247233634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/bulk-export-calendars-from-exchange.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1931003273247233634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1931003273247233634'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/bulk-export-calendars-from-exchange.html' title='Bulk export calendars from Exchange mailboxes'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_GxzZCShiNW8/SudCs0KoBKI/AAAAAAAAAH8/kQFJyybCejk/s72-c/2009-10-27+01-47-19+PM.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-4435461895824968957</id><published>2009-10-14T15:39:00.029+02:00</published><updated>2009-10-28T19:15:08.747+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><title type='text'>Collecting Exchange database white space from the event log using .NET</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;A recent comment from a reader, prompted me to do some updates and bug fixes to my Exchange 2007 audit script. As a part of this process, I decided to add the white space count into the mailbox store check.&lt;br /&gt;
&lt;br /&gt;
I discovered an extremely helpful post, as usual, from Shay Levy, which pointed me in the right direction.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
Although this function does get exactly what I needed, I did however want to search for the white space by mailbox store name, in order to get the value, as each mailbox store was passed during the script processing.&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
I changed my script to use .NET instead of WMI for event logs so I decided to continue using this method for the white space as well.&lt;br /&gt;
&lt;br /&gt;
The basic script to collect the white space sizes from the event log using .NET is as follows:&lt;br /&gt;
&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;$now = Get-Date
$colMailboxStores = Get-MailboxDatabase -Server SERVER -Status | Sort-Object Name
$spaceLog=[System.Diagnostics.EventLog]::GetEventLogs('SERVER') | where {($_.LogDisplayName -eq "Application")}
&amp;nbsp;&amp;nbsp; 
foreach ($objMailboxStore in $colMailboxStores)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Host "..Getting database white space for" $objMailboxStore.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; $store = @{Name="store";Expression={$_.ReplacementStrings[1]}}
&amp;nbsp;&amp;nbsp;&amp;nbsp; $freeMB = @{Name="freeMB";Expression={[int]$_.ReplacementStrings[0]}}
&amp;nbsp;&amp;nbsp;&amp;nbsp; $whiteSpace = @()
&amp;nbsp;&amp;nbsp;&amp;nbsp; $whiteSpace += $spaceLog.entries | where {($_.TimeWritten -ge $now.AddDays(-1))} | where {($_.EventID -eq "1221")} | where {($_.ReplacementStrings[1] -match $objMailboxStore.Name)} | select $store,$freeMB -last 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; $whiteSpace.freeMB
&amp;nbsp; }
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This method is very slow, as it has to dredge through the entire event log for every database. It’s really not a problem if you have a small number of databases, but in a large environment like ours, with multiple mailbox servers, this could take ages to complete.&lt;br /&gt;
&lt;br /&gt;
It was was painful during testing to wait for the above script to complete and I really felt that the speed of this process should be increased, so instead I came up with the following solution:&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;$now = Get-Date
$spaceLog=[System.Diagnostics.EventLog]::GetEventLogs('SERVER') | where {($_.LogDisplayName -eq "Application")}
$db = @{Name="database";Expression={$_.ReplacementStrings[1]}}
$freeMB = @{Name="MB";Expression={[int]$_.ReplacementStrings[0]}}
$whiteSpace = $spaceLog.entries | where {($_.TimeWritten -ge $now.AddDays(-1))} | where {($_.EventID -eq "1221")} | select $db,$freeMB

($whitespace | where {$_.database -match $objMailboxStore.Name} | select -last 1).mb
&lt;/pre&gt;&lt;br /&gt;
The code above will collect all of the Event ID 1221’s for the last day and store them in a variable with the customised place holders from the expressions.&lt;br /&gt;
&lt;br /&gt;
This happens once per server only and any subsequent searches can be performed against the variable instead.&lt;br /&gt;
&lt;br /&gt;
The select statement at the end, also selects the last item in the list to ensure that you also look at the latest event for each database. This literally reduces the runtime of the script by a factor equal to the amount of databases on your server.&lt;br /&gt;
&lt;br /&gt;
I will be posting an update to the Exchange 2007 audit script soon, so stay tuned.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-4435461895824968957?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/4435461895824968957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/gathering-exchange-database-white-space.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4435461895824968957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4435461895824968957'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/gathering-exchange-database-white-space.html' title='Collecting Exchange database white space from the event log using .NET'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-38229986177494232</id><published>2009-10-06T14:03:00.033+02:00</published><updated>2009-10-28T19:13:16.285+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='ping'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='smtp'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='roundtrip'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Measure the SMTP roundtrip time to an external email address</title><content type='html'>&lt;div style="border: medium none; font-family: Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;a href="http://3.bp.blogspot.com/_GxzZCShiNW8/SsuPfPRFNZI/AAAAAAAAAHk/09700tfFVLI/s1600-h/script+processing.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_GxzZCShiNW8/SsuPfPRFNZI/AAAAAAAAAHk/09700tfFVLI/s320/script+processing.jpg" /&gt;&lt;/a&gt;In an attempt to be more proactive about Internet email delays, whether caused by our systems, or those of our ISP, I have written a script which tests the roundtrip time on SMTP mail.&lt;br /&gt;
&lt;br /&gt;
The basic idea behind the script is to send a message with a GUID, and wait for the return of that specific message. When that message returns, it measures the roundtrip time, and logs the result to disk. If the message is not returned within 30 mins, it will send you a warning message informing you of the problem.&lt;br /&gt;
&lt;br /&gt;
Finally, the script creates a nice JPG with the results up to the last run.&lt;br /&gt;
&lt;br /&gt;
Setting up and using this script is a little more complex than usual as it combines different technologies and resources to achieve its goal, which is to measure the roundtrip time on an actual SMTP message.&lt;br /&gt;
&lt;br /&gt;
To start off, the script sends a message using a standard .NET relay. On Powershell V2 you could use send-mailmessage instead. At this point, the message is time stamped in the subject, with the current date and time. The message is also marked with a distinguishable word “SMTPPing”&amp;nbsp; for the reply rule, and a random GUID, which aids in recognising the message when it returns.&lt;br /&gt;
&lt;br /&gt;
I use Gmail, as my “auto-reply” robot, as I am fairly certain that their infrastructure is robust and pretty stable. If you choose to use Gmail, you will need to setup a filter, which automatically forwards all mail with the word “SMTPPing” back to your email address, and then deletes it from Gmail.&lt;br /&gt;
&lt;br /&gt;
Once you are sure that the auto reply is working, you can configure the script with your SMTP email addresses and relay host.&lt;br /&gt;
&lt;br /&gt;
The return messages are collected from an Outlook mailbox using MAPI. You need to customise the script for the Outlook profile it needs to logon to. More details regarding this can be found as comments inside the script.&lt;br /&gt;
&lt;br /&gt;
Outlook does not like strangers poking around in your stuff, so it will constantly warn you about this. To get around this problem, and also be a little selective about what you allow, you can download an awesome free tool from MapiLab called &lt;a href="http://www.mapilab.com/outlook/security"&gt;Advanced Outlook Security&lt;/a&gt;.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Lastly, the script needs Excel installed, in order for the chart creation and export to JPG.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="border: medium none; text-align: left;"&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SsuSKeYTjJI/AAAAAAAAAHs/cVQMNgk37ck/s1600-h/smtpPing_6-10-2009.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img $r="true" border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SsuSKeYTjJI/AAAAAAAAAHs/cVQMNgk37ck/s320/smtpPing_6-10-2009.jpg" /&gt;&lt;/a&gt;I am not sure why, but I am having problems currently closing Excel. Although I issue the command to close the application, it sometimes remains running, so lookout for excel.exe in process monitor.&lt;br /&gt;
&lt;br /&gt;
As usual, your comments and suggestions are always welcome.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The script can be downloaded from here:&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/get-smtproundtrip.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-38229986177494232?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/38229986177494232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/measure-smtp-roundtrip-time-to-external.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/38229986177494232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/38229986177494232'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/10/measure-smtp-roundtrip-time-to-external.html' title='Measure the SMTP roundtrip time to an external email address'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_GxzZCShiNW8/SsuPfPRFNZI/AAAAAAAAAHk/09700tfFVLI/s72-c/script+processing.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1621216601386095846</id><published>2009-09-18T13:24:00.037+02:00</published><updated>2009-10-28T19:12:01.996+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Updated basic Exchange queue monitor</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif; text-align: left;"&gt;As an update to the queue monitor script, I have added a little tweak.&lt;br /&gt;
&lt;br /&gt;
When the script has completed its run, it will now import the log file into Excel and create a chart displaying the message flow for the current log.&lt;br /&gt;
&lt;br /&gt;
The Excel chart export seems to have a problem with the current folder. I tried using “.\” or even get-location and set location in variables, but it only works if I hard code the path.&lt;br /&gt;
&lt;br /&gt;
This image can be used on a web page to display the queue information in more friendly and accessible format.Excel is set to overwrite the existing image and spreadsheet everytime the script runs.&lt;br /&gt;
&lt;br /&gt;
An awesome source of Excel related information can be located at the &lt;a href="http://olddogsblog.spaces.live.com/blog/cns%21C2DB05EEFA6C21A1%21129.entry?sa=951986484"&gt;Excel Cookbook&lt;/a&gt;. This information saved me a lot of time an effort while working with Excel.&lt;br /&gt;
&lt;br /&gt;
Information regarding Excel chart types and styles can be &lt;a href="http://it.toolbox.com/wiki/index.php/EXCEL_Chart_Type_Enumeration"&gt;found here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The complete script with the Excel chart export section can be downloaded from here:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/get-messagecount.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1621216601386095846?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1621216601386095846/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/updated-basic-exchange-queue-monitor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1621216601386095846'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1621216601386095846'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/updated-basic-exchange-queue-monitor.html' title='Updated basic Exchange queue monitor'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-3512950146646613740</id><published>2009-09-17T08:12:00.004+02:00</published><updated>2009-11-04T22:15:15.825+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>A very basic queue monitor</title><content type='html'>&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;At my office we recently needed a method to quickly know if the queues on any of the Exchange servers were building up. We have monitoring in place, but these guys can sometimes miss a build-up which leaves us with the problem.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;As a very rudimentary solution, I compiled the following script.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;In a nutshell, it enumerates the message count of all the queues on all Exchange servers in the Org. This includes Exchange 2003 and 2007. The script then measures the sum total of all messages. If it exceeds a predetermined amount, 1000 in my case, it will send a notification message to the administrators.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;This is really a catch 22, if the server with the queue build-up is also your relay host, or happens to be the server with the problem. As a workaround for this you could probably do a NET SEND message or use 2 SMTP servers to relay the message through. An alternative is to send an SMS to administrators if you have the facility.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;Initially the script waited with a while loop and polled the queues every 5 minutes. I have opted to change that, and launch the script with Task Scheduler instead, which means I don’t have to actually be logged onto the console for the script to run.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;The script writes out the date and message count to a log. This log cycles daily. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;I know this is very basic, but it gets the job done in terms of what we needed as an interim solution.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;You can download the script here: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/get-messagecount.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-3512950146646613740?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/3512950146646613740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/very-basic-queue-monitor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3512950146646613740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3512950146646613740'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/very-basic-queue-monitor.html' title='A very basic queue monitor'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-7145213095337100627</id><published>2009-09-01T10:48:00.008+02:00</published><updated>2009-10-28T19:07:06.425+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='cleanup'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Updated: Exchange Mailbox Cleaner</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_GxzZCShiNW8/Suh5_YI5szI/AAAAAAAAAKE/RW6iaN1O_yk/s1600-h/ScreenHunter_02+Sep.+01+10.19.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_GxzZCShiNW8/Suh5_YI5szI/AAAAAAAAAKE/RW6iaN1O_yk/s320/ScreenHunter_02+Sep.+01+10.19.gif" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&amp;nbsp;I am ready to call this the final version of my Exchange Mailbox Cleaner script. &lt;br /&gt;
&lt;br /&gt;
I have successfully used it in production and it saved us the effort of having to find and remove these mailboxes manually. &lt;br /&gt;
&lt;br /&gt;
The GUI also makes it easy to hand this function over to the administrators for future cleanup tasks. &lt;br /&gt;
&lt;br /&gt;
I have added one more search query button, the “Last Logon” button. This button will look for users on the selected server where the LastLogon is equal to $null.&amp;nbsp; This finds accounts which have essentially never logged on. There is a small bug though, if the user name is not unique, it seems that the last logon is unreadable and the account will also show up in the list. &lt;br /&gt;
&lt;br /&gt;
This will however report an ERROR to the shell screen. Mailboxes which have not logged on will report the following warning to the shell: &lt;br /&gt;
&lt;br /&gt;
WARNING: There is no data to return for the specified mailbox 'Bunny, Bugs', because it has not been logged on to. &lt;br /&gt;
&lt;br /&gt;
For now, this is a manual method of verifying that the correct mailboxes will be removed. I am however looking for a way to avoid this and will post an update as soon as I have time to find the solution. &lt;br /&gt;
&lt;br /&gt;
I have also permanently removed the Add-ADPermission from the Export-Mailbox section, as full mailbox access permissions are enough to export the mailbox. &lt;br /&gt;
&lt;br /&gt;
I may build in a check later to see if the permissions are required before adding them. &lt;br /&gt;
&lt;pre class="brush: powershell"&gt;#Add-ADPermission -Identity $actionItem -User $currentUser -Extendedrights "Send As" -whatif 
#Add-ADPermission -Identity $actionItem -User $currentUser -Extendedrights "Receive As" -whatif 
&lt;/pre&gt;As always, any comments / suggestions with regards to the script are always welcome. &lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;A little disclaimer / warning: This is a dangerous utility, and can wreck your Exchange system if you are not careful. Please test this in your test environment first, and adhere to your change control procedures before using this utility in the live environment. I take absolutely no responsibility for any damage caused by using this tool.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The utility requires the Exchange Management shell, and if launched from a Vista / Windows 7 needs to be “Run as Administrator”&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
This script was tested under Windows 7 Powershell v2 The script can be downloaded from here:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/clean-exchange.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-7145213095337100627?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/7145213095337100627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/updated-exchange-mailbox-cleaner.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7145213095337100627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/7145213095337100627'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/09/updated-exchange-mailbox-cleaner.html' title='Updated: Exchange Mailbox Cleaner'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_GxzZCShiNW8/Suh5_YI5szI/AAAAAAAAAKE/RW6iaN1O_yk/s72-c/ScreenHunter_02+Sep.+01+10.19.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-6412320323497980850</id><published>2009-08-19T13:23:00.007+02:00</published><updated>2009-10-28T19:00:47.145+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><title type='text'>Maximize My SendSize</title><content type='html'>Someone asked me the other day, “How could I go about using Security Groups, to control users’ send size limits?” He basically had a limit of 2mb for all users, and wanted to allow users in a specific Security Group to send up to 50mb messages. Here is a basic breakdown of the process I suggested: Firstly, you need to confirm that the global transport limit is raised to 50mb. &lt;br /&gt;
&lt;br /&gt;
You can view and set these limits using get-transportconfig and set-transportconfig respectively:&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;Get-TransportConfig | select MaxSendSize&amp;nbsp; 
&lt;/pre&gt;The next step would involve setting the send connector to allow 50mb messages. You can use get-sendconnector to get a list of all send connectors, and their respective limits.&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;Get-SendConnector | Select Name, MaxMessageSize&amp;nbsp;&amp;nbsp; 
&lt;/pre&gt;And then use set-sendconnector to set the MaxSendSize Set-SendConnector “Connector Name” –MaxSendSize 50mb Finally, you need to control the individual users’ send limits. If you have to control it via groups, you can use the following command to first enumerate the users in the group, and then pipe that to the set-mailbox command. Replace testsizegroup with the group you need to control the size limits for.&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;((get-group "testsizegroup").members) | foreach {set-mailbox -identity $_.Name -maxsendsize 52428800}
&lt;/pre&gt;This will set the MaxSendSize for all users in that group to 50 mb. This command will have to be rerun every time to add users to the group, so it would be advisable to schedule this command to run hourly / daily etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-6412320323497980850?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/6412320323497980850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/maximize-my-sendsize.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/6412320323497980850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/6412320323497980850'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/maximize-my-sendsize.html' title='Maximize My SendSize'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-3953455507668977448</id><published>2009-08-17T08:15:00.004+02:00</published><updated>2009-10-28T12:39:39.965+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='users'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='quest'/><title type='text'>The OWA saga continues...</title><content type='html'>&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;After solving the msExchVersion mystery, it has become apparent that even more of our Exchange 2007 users were unable to access OWA.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt; &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;After logging onto the site, a very similar error is displayed:  &lt;span style="font-style: italic;"&gt;Exception type: Microsoft.Exchange.Data.Storage.StoragePermanentException&lt;/span&gt; &lt;span style="font-style: italic;"&gt;Exception message: There was a problem accessing Active Directory.&lt;/span&gt;  My first step was obviously to verify the msExchVersion.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;After ensuring that this was correct, and that the users were still unable to use OWA, I had to do more digging.  Deeper delving into this issue, yielded the following KB from Microsoft:  &lt;a href="ttp://support.microsoft.com/kb/949527"&gt;http://support.microsoft.com/kb/949527&lt;/a&gt;  &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;To use OWA the Exchange Servers group must have write permissions to the msExchUserCulture attribute.  Easy to resolve, just allow inheritable permissions from the parent to filter to the faulty object / objects, as per the KB article.  &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Trebuchet MS&amp;quot;,sans-serif;"&gt;Easy enough on one account, but if you had to change this setting manually on multiple accounts, you could use &lt;span style="font-style: italic; font-weight: bold;"&gt;Set-QADObjectSecurity –UnlockInheritance&lt;/span&gt; to accomplish the task.  For more information see &lt;a href="http://dmitrysotnikov.wordpress.com/2008/06/04/find-and-fix-broken-inheritance/"&gt;Dimitri’s blog&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-3953455507668977448?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/3953455507668977448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/owa-saga-continues.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3953455507668977448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3953455507668977448'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/owa-saga-continues.html' title='The OWA saga continues...'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-9016756367760431279</id><published>2009-08-05T09:53:00.006+02:00</published><updated>2009-10-28T18:59:43.148+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='users'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Legacy mailboxes on Exchange 2007</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;One of our users had a problem logging onto OWA today, and I noticed that the icon for his mailbox in the GUI displayed as a legacy mailbox, although he was located on an Exchange 2007 mailbox server.&lt;br /&gt;
&lt;br /&gt;
After countless searches, I came across this article:&lt;a href="http://support.microsoft.com/kb/941146"&gt; http://support.microsoft.com/kb/941146.&lt;/a&gt; It explains that the msExchVersion property on the AD object is not set correctly, and that using set-mailbox –ApplyMandatoryProperties would resolve the problem. Looking at the help information on set-mailbox this could also be caused by users being created on Exchange 2007 server using the Exchange 2003 tools, although these users were migrated from Exchange 2003.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;So, how to correct this? First get a list of all mailboxes on the Exchange 2007 server with the incorrect version. Using get-mailbox, the incorrect Exchange version displays as 0.0 (6.5.6500.0) The following command returns a list of these mailboxes by server (where SERVER1 is your Exchange 2007 server):&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;get-mailbox -server SERVER1 -resultsize unlimited | where {$_.ExchangeVersion -like "*0.0*"} | select Name, ExchangeVersion
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Once you verify the list, pipe them to set-mailbox.&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;get-mailbox -server SERVER1 -resultsize unlimited | where {$_.ExchangeVersion -like "*0.0*"} | Set-Mailbox –ApplyMandatoryProperties  
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
This resolved the problem for me, easily, on multiple Exchange mailboxes. Running the get-mailbox command again, returned no results after applying set-mailbox to the problematic mailboxes.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-9016756367760431279?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/9016756367760431279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/legacy-mailboxes-on-exchange-2007.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/9016756367760431279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/9016756367760431279'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/08/legacy-mailboxes-on-exchange-2007.html' title='Legacy mailboxes on Exchange 2007'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-4615601643477463214</id><published>2009-07-30T15:04:00.008+02:00</published><updated>2009-10-28T18:56:55.594+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='windows forms'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='cleanup'/><title type='text'>Updated: Exchange Mailbox Cleaner</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SnJ9dAUtg9I/AAAAAAAAAFE/A7CUqqLO7j4/s1600-h/exc.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5364488043408229330" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SnJ9dAUtg9I/AAAAAAAAAFE/A7CUqqLO7j4/s200/exc.gif" style="cursor: pointer; float: right; height: 150px; margin: 0pt 0pt 10px 10px; width: 200px;" /&gt;&lt;/a&gt;I have really been busy lately and have not had much time to spend on scripting. I did however find a litlle time to update this utility.  Here is a list of changes:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;- After completing a query, the utility will now show you the total amount of data used by the mailboxes. (this obviously ignores single instance storage etc.)&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;- You can now use the utility to move selected mailboxes to another store (This was a request from Aaron)&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;- I have force removed the mandatory “confirm” on the Exchange verbs (move, disabled and delete)&amp;nbsp;&lt;/span&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;i&gt;&lt;span style="font-weight: bold;"&gt;WARNING: &lt;/span&gt;This is a dangerous utility, and can wreck your Exchange system if you are not careful. Please test this in your test environment first, and adhere to your change control procedures before using this utility in the live environment.  I take absolutely no responsibility for any damage caused by using this tool.  The utility requires the Exchange Management shell, and if launched from a Vista / Windows 7 needs to be “Run as Administrator”    The script can be downloaded from here:&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/clean-exchange.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-4615601643477463214?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/4615601643477463214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/07/updated-exchange-mailbox-cleaner.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4615601643477463214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/4615601643477463214'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/07/updated-exchange-mailbox-cleaner.html' title='Updated: Exchange Mailbox Cleaner'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_GxzZCShiNW8/SnJ9dAUtg9I/AAAAAAAAAFE/A7CUqqLO7j4/s72-c/exc.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-3506543212602456662</id><published>2009-06-30T17:08:00.009+02:00</published><updated>2009-10-28T16:06:03.808+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='users'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='mailbox'/><category scheme='http://www.blogger.com/atom/ns#' term='cleanup'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Cleanup unused Exchange 2007 mailboxes</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I often use my &lt;a href="http://powershellneedfulthings.blogspot.com/2009/05/update-automatically-clean-up-orphaned.html"&gt;orphaned home directory cleanup script&lt;/a&gt; at work, to recover unused space from our file and print clusters. So my manager recently suggested that I do something similar for Exchange.  Knowing that the orphan folder cleanup utility is still my responsibility as the administrators are not too comfortable with running scripts, I decided to give this utility a nice GUI.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;To generate the code for the forms, I used &lt;a href="http://www.primaltools.com/downloads/communitytools/"&gt;SAPIEN PrimalForms&lt;/a&gt;. What beautiful tool. Very short learning curve, and very, very powerful. &lt;a href="http://3.bp.blogspot.com/_GxzZCShiNW8/SkouRm8cXpI/AAAAAAAAAEs/fmLe6Qh9Yyw/s1600-h/embxcleaner.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5353141987129974418" src="http://3.bp.blogspot.com/_GxzZCShiNW8/SkouRm8cXpI/AAAAAAAAAEs/fmLe6Qh9Yyw/s320/embxcleaner.gif" style="cursor: pointer; float: right; height: 239px; margin: 0pt 0pt 10px 10px; width: 320px;" /&gt;&lt;/a&gt; When the form loads, it will get a list of all the Exchange mailbox servers using get-mailboxserver.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt; This excludes Exchange 2003 servers as get-mailboxstatistics does not work with legacy mailboxes. I may develop a solution for that later.  The three query buttons (Disabled, Hidden, Stale) will perform the following actions respectively:  Disabled – Find mailboxes linked to disabled AD accounts Hidden – Find mailboxes hidden from the address book.&amp;nbsp; Stale – Find mailboxes linked to accounts which have not logged on in the last 3 months.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This search may take a little time to complete and this button is not supported against Exchange 2003 servers.  These queries will populate the listbox with the names of the mailboxes.  Besides the “Export List” button, the Action buttons at the bottom will action only selected items.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt; You can select items using SHIFT or CTRL. Export List will create a text file containing your search results.  Export PST will grant the current user Full Mailbox with Send As and Receive As permission, and then export the mailbox to the path specified.  Rename will change the display name based on the query performed. For mailboxes found with the “Disabled” button the display name will be prefixed with “DISABLED-MBXCleaner-“, for “Hidden” with “HIDDEN-MBXCleaner-“ and so forth.  Users previously renamed will be excluded from subsequent searches.  The “Disable” action will remove Exchange Attributes without deleting the AD account. The mailbox will be removed when the retention time expires.  Delete will remove the mailbox and AD account completely.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I have not had a chance to test the Delete button as I would need to submit a change control request before using the utility in our live environment.  All of the Action buttons are set to –whatif mode by default. The “Go Hot” checkbox will activate the heavy hitters (Export PST; Rename; Disable and Delete) so you can safely test each button first before taking any action.  The “Reserved” button, currently, does nothing. I plan to allow this button to read or build a custom search for users, either by Name or other criteria.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;span style="font-weight: bold;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;i&gt;&lt;span style="font-weight: bold;"&gt;WARNING: &lt;/span&gt;This is a dangerous utility, and can wreck your Exchange system if you are not careful. Please test this in your test environment first, and adhere to your change control procedures before using this utility in the live environment.  I take absolutely no responsibility for any damage caused by using this tool.  The utility requires the Exchange Management shell, and if launched from a Vista / Windows 7 needs to be “Run as Administrator”  The script can be downloaded from here:&lt;/i&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;  &lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/clean-exchange.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-3506543212602456662?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/3506543212602456662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/cleanup-unused-exchange-2007-mailboxes.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3506543212602456662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3506543212602456662'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/cleanup-unused-exchange-2007-mailboxes.html' title='Cleanup unused Exchange 2007 mailboxes'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_GxzZCShiNW8/SkouRm8cXpI/AAAAAAAAAEs/fmLe6Qh9Yyw/s72-c/embxcleaner.gif' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-5852318092291789145</id><published>2009-06-12T14:40:00.024+02:00</published><updated>2009-10-28T16:03:17.428+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='event logs'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>Whats going on here?</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;As part of the Exchange audit scripts, I recently changed the 2007 version of the script to use .NET to collect the event logs instead of WMI. Virtu-Al made an interesting suggestion, which was to say, which of these methods are quicker at collecting the logs. So in order to do this I needed to setup a race. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This race would basically involve the two methods of retrieval collecting a large list of events from a selected server. The basic command to accomplish this is as follows:  For WMI one would simply use:  &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;$wmi = Get-WmiObject -computer SERVER1 Win32_NTLogEvent  
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Using .NET, it retrieves the actual Event Logs, so the entries have to be enumerated with a quick bit of code:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;System.Diagnostics.EventLog]::GetEventLogs('SERVER1') ForEach ($eventLog in $eventLogs){ $dotNet += ($eventLog.entries)} 
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;In both cases, where SERVER1 is the name of the remote server you need to collect the events from. Now, in order to make sure that there is no cheating, I would have to count how many objects are returned by each method. This could be done by simply saving the collection to a variable and counting the total. So in this scenario, .NET would return approximately 56000 items and WMI would return less. About 500+ less every time. From here I went down a crazy path of checking date and time formats etc. and in the end, I came to the conclusion that it had to be the security log. Entries were being written into the Security Log so quickly, that by the time the 2nd script is run, the number of entries have changed, or I remembered that you needed special permissions to read certain Security Log entries. Or so I thought. So I decided to exclude the Security log from my collection. This was easy enough, but still the totals were inconsistent. In an effort to try and eliminate where the problem could be, I decided to include only one log at a time, starting with the Application Log. Here is the script used to collect the Application from a remote server using WMI:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;$d1 = get-date

$wmiDate = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-1))
$WMI = Get-WmiObject -computer SERVER1 -query ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and TimeWritten &amp;gt;='" + $WmiDate + "'")

$wmiCount = ($WMI).Count

$wmiDT = [System.Management.ManagementDateTimeConverter]::ToDateTime($wmiDate)
Write-Host From Date $wmiDT
Write-Host Total $wmiCount
$d2 = Get-Date
$d2 - $d1
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;WMI Script results: From Date 09/06/2009 01:28:49 PM Total 317 Here is the script used to collect the same event log entries from the same server, using .NET instead:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;$d1 = get-date
$dotNetDate = ([DateTime]::Now.AddDays(-1))
$eventLogs=[System.Diagnostics.EventLog]::GetEventLogs('SERVER1') | where {$_.LogDisplayName -eq "Application"}
ForEach ($eventLog in $eventLogs ){

$dotNet += ($eventLog.entries) | where {($_.TimeWritten -ge $dotNetDate)}
}

$dotnetCount = ($dotNet).count

Write-Host From Date $dotNetDate
Write-Host Total $dotnetCount
$d2 = Get-Date
$d2 - $d1
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;.NET Script Results: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;From Date 09/06/2009 01:28:49 PM Total 650 &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This was still very confusing so, to see exactly at which record the problem is, I had both scripts display the record number of the first and last record in each respective collection, by adding the following to each script: For the .NET script: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;$dotNet | Select-Object -First 1 $dotNet | Select-Object -Last 1 For the WMI script: $WMI | Select-Object RecordNumber, TimeWritten, Type, SourceName, EventCode -First 1 $WMI | Select-Object RecordNumber, TimeWritten, Type, SourceName, EventCode -Last 1 
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Now I could see that, at least they were starting at the same record, but for some odd reason, WMI was quitting before the job was done. .NET record results: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Index Time Type Source EventID ----- ---- ---- ------ ------- 51 Jun 09 14:55 Warn MSExchange Availa... 4004 705 Jun 10 14:51 Warn MSExchange Active... 1008 WMI Results: RecordNumber TimeWritten Type SourceName ------------ ----------- ---- ---------- 353 20090610012624.00000... Warning MSExchange ActiveSync RecordNumber TimeWritten Type SourceName ------------ ----------- ---- ---------- 51 20090609145522.00000... Warning MSExchange Availability &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;To make sure this problem wasn’t specific to the current server I started collecting logs from other servers, to record the results. I also did an add-member on the WMI script to convert the time and date back for easier reading. With the following string: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;ForEach-Object { Add-Member -inputobject $_ -Name myTime -MemberType NoteProperty -Value ([System.Management.ManagementDateTimeConverter]::ToDateTime($_.TimeWritten)) -Force -PassThru} 
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Over a number of servers this still made no difference, WMI still did not return all the results. This seems to be a problem specific to the Application and Security Log, and could well be related to the WMI impersonation or authentication which will be available in version 2. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This I have not had time to investigate. I decided to re-write the WMI script to collect all results and then filter out the unwanted events with “where-object”. At this point I also changed the selected log to the system event log, as someone cleared the application logs on the selected servers. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This worked great for most of the servers and finally I was getting similar results from both scripts. I did however find, that servers with large numbers of events generate a WMI Quota Violation, which seems to imply that there are too many items in the list, which is yet another blow to WMI. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This could also explain the incomplete results from previous attempts. The Quota Violation is a known problem and there is a resolution for it posted here: http://support.microsoft.com/kb/828653. To get around this problem, I changed the script again, to use the WMI query. So now that we were getting results, it was time to start testing the speed of each method. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I decided to test the speed against 3 different servers, and increment the number of records retrieved until I could not collect anymore, or up to a maximum of 240 days worth of events. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I decided to also give each method and average read time over 3 attempts. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Here are some of the results: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_GxzZCShiNW8/SuhOrp6qDQI/AAAAAAAAAJs/-95XNPIvV9Q/s1600-h/ScreenHunter_05+Jun.+12+14.33.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_GxzZCShiNW8/SuhOrp6qDQI/AAAAAAAAAJs/-95XNPIvV9Q/s320/ScreenHunter_05+Jun.+12+14.33.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhOtcXqaVI/AAAAAAAAAJ0/o9SAl7WRPhg/s1600-h/ScreenHunter_04+Jun.+12+14.32.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhOtcXqaVI/AAAAAAAAAJ0/o9SAl7WRPhg/s320/ScreenHunter_04+Jun.+12+14.32.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/_GxzZCShiNW8/SuhOvWZk2VI/AAAAAAAAAJ8/QReRKyTA7nc/s1600-h/ScreenHunter_03+Jun.+12+14.32.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_GxzZCShiNW8/SuhOvWZk2VI/AAAAAAAAAJ8/QReRKyTA7nc/s320/ScreenHunter_03+Jun.+12+14.32.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As the amout of days, or number of records increase, the read speed of WMI starts decreasing. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;In summary, WMI scales nicely when using a WMI query directly in the Get-WMIObject command. It does however loose speed as the number of records to retrieve start increasing. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;It has to be mentioned, that WMI slows down to a crawl, if all records are retrieved and the result is filtered with “where-object”. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Although WMI is faster with less records, I am going base all my event log queries on .NET for now, as WMI proved to be inconsistent and erroneous in what retrieves, or atleast in my testing it did. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I hope that this problem is related to impersonation, and that it is resolved in Powershell v2. The final scripts I used to retrieve the information can be downloaded from here: &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/get-eventsnet.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;  &lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/get-eventswmi.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-5852318092291789145?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/5852318092291789145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/whats-going-on-here.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/5852318092291789145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/5852318092291789145'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/whats-going-on-here.html' title='Whats going on here?'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_GxzZCShiNW8/SuhOrp6qDQI/AAAAAAAAAJs/-95XNPIvV9Q/s72-c/ScreenHunter_05+Jun.+12+14.33.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-2833838192376380145</id><published>2009-06-05T10:30:00.011+02:00</published><updated>2009-11-13T15:29:17.522+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Update: Exchange 2007 audit script</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;In an attempt to resolve some issues with regards to the event logs, I have made a few updates to the Exchange 2007 audit script:&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* I now use [System.Diagnostics.EventLog]::GetEventLogs() to collect the remote event logs and entries instead of WMI&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* The output to the host displays exactly which event log it is busy reading.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* The date range seems more accurate now when the event log contains a large amount of data.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* The physical memory on the basic server information is now displayed as GB and is neatly rounded.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* The Mailbox stores are sorted in alphabetical order by Store Name.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;* Added more verbose output to the console while the script runs, to give a better indication of what the script is busy with.&lt;/span&gt; &lt;ol style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/ol&gt;&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/ul&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I hope this resolves most of the problems for now, comments / suggestions are always welcome. The script can be downloaded from here:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;This script has been replaced by a later version, please check the following link, or download the updated version below:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html"&gt;http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/test-exchange2k7_V3.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-2833838192376380145?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/2833838192376380145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/update-exchange-2007-audit-script.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2833838192376380145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2833838192376380145'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/06/update-exchange-2007-audit-script.html' title='Update: Exchange 2007 audit script'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-2650844889927864277</id><published>2009-05-21T10:30:00.010+02:00</published><updated>2009-11-13T15:30:59.814+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Exchange 2007 Audit Report</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I had some extra time this week to complete the Exchange 2007 version of the Audit script, as I am going on leave for a week, and needed to have the process automated while I am gone. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
This version of the script still uses WMI for some of the items on the report, but uses the Exchange 2007 commandlets for most of the Exchange related information. &lt;br /&gt;
&lt;br /&gt;
The one tricky bit of information to retrieve was the installed Exchange rollups. These are not available via WMI or any other method I could find. I did find a very effective solution on flaphead.com. This little piece of magic, locates the installed patches in the remote registry, and loops through the keys to find and list the installed rollups. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhLS_ZUGHI/AAAAAAAAAJc/bXvqY1r2_Qo/s1600-h/rollups.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhLS_ZUGHI/AAAAAAAAAJc/bXvqY1r2_Qo/s320/rollups.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
Unlike Exchange 2003, Exchange 2007 servers are installed with specific roles. This plays a part, when checking things like queues and mailbox stores. For instance, there is no point in checking a pure Hub Transport server for mailbox stores etc. I initially built in a check which would check the ServerRole property of the server to match a specific role, forgetting that one server could have multiple roles. I now do a match for the role anywhere in the property string with this if statement: if ($exServer.ServerRole -notlike "*Mailbox*") This will skip the mailbox related check if the word “Mailbox” cannot be located anywhere in the string. &lt;br /&gt;
&lt;br /&gt;
To automate the running of the checks on a daily basis I setup a scheduled task on one of my Exchange 2007 servers as the script requires the commandlets. &lt;br /&gt;
&lt;br /&gt;
I really had no idea how to get the scheduled task to run in the Exchange management shell so, as a test I basically used the following command: C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "D:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" c:\scripts\ExchangeAudit2k7.ps1 .\servers.txt &lt;br /&gt;
&lt;br /&gt;
This did the trick and the entire check process now runs and completes before I even get to work. My version of the script, also creates an HTML menu and moves the reports to our departmental web server for my managers’ viewing pleasure. The mailbox stores now also indicate the last backup time, as we have had issues before where the backups aren't completed, and we don’t find out until it’s too late. &lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhLi7TcenI/AAAAAAAAAJk/KwvdCeH4OUU/s1600-h/stores.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhLi7TcenI/AAAAAAAAAJk/KwvdCeH4OUU/s320/stores.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
I am busy working on a little piece of code, which will connect to the OWA site and simply test if the site is available, but that will have to wait until I am back from leave.&lt;br /&gt;
&lt;br /&gt;
This script has been replaced by a later version, please check the following link, or download the updated version below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html"&gt;http://powershellneedfulthings.blogspot.com/2009/11/exchange-2007-audit-script-version-3.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/test-exchange2k7_V3.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-2650844889927864277?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/2650844889927864277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/exchange-2007-audit-report.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2650844889927864277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2650844889927864277'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/exchange-2007-audit-report.html' title='Exchange 2007 Audit Report'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_GxzZCShiNW8/SuhLS_ZUGHI/AAAAAAAAAJc/bXvqY1r2_Qo/s72-c/rollups.jpg' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1202661500194281892</id><published>2009-05-19T16:54:00.006+02:00</published><updated>2009-10-28T15:42:42.115+02:00</updated><title type='text'>First version of my PowerPack uploaded</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I really wanted to see how complicated it would be to write a very basic PowerPack for PowerGUI. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I had recently updated my WMI defrag script to report to HTML, so I thought this would be an excellent candidate for a PowerPack. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhJ7q495SI/AAAAAAAAAJU/qY5v_soBijo/s1600-h/WMIDefrag.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhJ7q495SI/AAAAAAAAAJU/qY5v_soBijo/s200/WMIDefrag.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I must admit that, at first it is not very straight forward, but the more time you spend on it the easier it becomes. I am really looking forward to re-create some of my favorite apps / scripts as PowerPacks. I think this is an excellent platform from Quest.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://www.powergui.org/entry.jspa?externalID=2384&amp;amp;categoryID=53"&gt;More info and download of the PowerPack is available here&lt;/a&gt;. &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Suggestions / comments always welcome. Have mercy, it’s my first attempt at a PowerPack.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1202661500194281892?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1202661500194281892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/first-version-of-my-powerpack-uploaded.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1202661500194281892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1202661500194281892'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/first-version-of-my-powerpack-uploaded.html' title='First version of my PowerPack uploaded'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_GxzZCShiNW8/SuhJ7q495SI/AAAAAAAAAJU/qY5v_soBijo/s72-c/WMIDefrag.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-3609665586789143620</id><published>2009-05-18T08:45:00.003+02:00</published><updated>2009-10-28T15:37:51.031+02:00</updated><title type='text'>Update: Automatically clean up orphaned user directories</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;As an update to the automatic cleanup script, this script will do essentially the same, but will also attempt to take ownership of the folder before renaming it. This was added because some of our users had full control on their folders, and removed all other permission from the folder. &lt;br /&gt;
&lt;br /&gt;
There is a slight problem with get-acl and set-acl. The ownership will fail if you can’t read the ACL. If that fails, as a last resort, the script writes the failures out to a text file, which can be used as a batch file with a little utility called takeown.exe which will take ownership of the folders regardless. On a re-run of the script, the rename will succeed.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;You can download the script from here:&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/FindOrphan.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-3609665586789143620?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/3609665586789143620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/update-automatically-clean-up-orphaned.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3609665586789143620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3609665586789143620'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/update-automatically-clean-up-orphaned.html' title='Update: Automatically clean up orphaned user directories'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-2436301821949221796</id><published>2009-05-12T11:17:00.007+02:00</published><updated>2009-10-28T15:36:22.324+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='defrag'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Update: Powershell Remote WMI Defrag</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_GxzZCShiNW8/SuhIY_hWV_I/AAAAAAAAAJE/0tIxKXHD-mg/s1600-h/ScreenHunter_01+May.+18+07.53.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_GxzZCShiNW8/SuhIY_hWV_I/AAAAAAAAAJE/0tIxKXHD-mg/s320/ScreenHunter_01+May.+18+07.53.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;As with most things in life, people are only happy with limited features for a little while, and then the enhancement requests pour in. &lt;br /&gt;
The administration guys at the office have been using the remote defrag script for a couple of weeks, and soon realised that there was no way for them to show off the results of their labour to management. So inevitably, they requested that I add some sort of reporting to the script which they can send to management. &lt;br /&gt;
&lt;br /&gt;
Initially, I had all the results write out to a text file, for each volume, but this became a mess to manage after you defrag hundreds of servers with multiple volumes. Having recently completed the Exchange 2003 audit script with the use of Virtu-Al’s HTML template, I imagined it would be possible to report the defrag results using a similar format. &lt;br /&gt;
&lt;br /&gt;
The script runs through a list of servers, contained in servers.txt and starts a remote defrag using WMI. It waits for the process to complete and then moves on to the next volume. The script will check if dfrgntfs.exe is running on the remote host, and then skip that server.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhIgUhiiVI/AAAAAAAAAJM/NB9ycUuDjWA/s1600-h/ScreenHunter_02+May.+18+07.54.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_GxzZCShiNW8/SuhIgUhiiVI/AAAAAAAAAJM/NB9ycUuDjWA/s320/ScreenHunter_02+May.+18+07.54.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;The script changes the colour of the drive on the report, based on whether a defrag was actually run or not. Green means it was skipped, orange that defrag was already running and red that it was defragged.&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;Finally, at the bottom of each drives’ report the script will give you a quick before and after result.&lt;br /&gt;
&lt;br /&gt;
The script can be downloaded from my Skydrive:&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/RemoteDefrag.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-2436301821949221796?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/2436301821949221796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/update-remote-wmi-defrag.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2436301821949221796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2436301821949221796'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/update-remote-wmi-defrag.html' title='Update: Powershell Remote WMI Defrag'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_GxzZCShiNW8/SuhIY_hWV_I/AAAAAAAAAJE/0tIxKXHD-mg/s72-c/ScreenHunter_01+May.+18+07.53.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-485030117331444586</id><published>2009-05-07T13:47:00.012+02:00</published><updated>2009-10-28T15:25:29.226+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='exchange'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><title type='text'>Exchange WMI Audit</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;I recently needed to automate my Exchange 2003 server daily checks. I have done some basic work on this before, but I really needed to automate the process and write the results to HTML to make it more “manager friendly”. &lt;br /&gt;
&lt;br /&gt;
While searching the web for something I could use as a basic start up script, I came across an awesome script on Virtual-Al. This script uses WMI to audit a list of remote computers, and reports in a very neat HTML format. It was exactly the platform I needed, and it meant not having to re-invent the wheel. &lt;br /&gt;
&lt;br /&gt;
I did however have some trouble with WMI and the mailbox stores, and finding a method for reporting the number of users and whether the store is mounted or not. I managed to find a workaround for the number of users, but it seems that checking the store status would have to be done with CDOEXM. This felt like a little too much effort as we are in the middle of our migration to Exchange 2007. &lt;br /&gt;
&lt;br /&gt;
Speaking of Exchange 2007. The script cannot be used against Exchange 2007 servers, as Exchange 2007 does not include any WMI providers. &lt;br /&gt;
I am however working on an Exchange 2007 version or an Exchange version check process for this script. All credit for the HTML template and the original script should go to Alan Renouf, I merely took a great script and adapted it for use with Exchange. &lt;br /&gt;
&lt;br /&gt;
The script will show only Exchange related information on the report, this includes Hotfixes, Services and Event Log entries. The version of the script which I use myself, creates an HTML menu, with a list of all of the servers processed and links to their individual reports. It also moves the files to a web server, which makes it much more automated. Comments and suggestions are always welcome. &lt;br /&gt;
&lt;br /&gt;
This script is not displayed in a code window, but can be downloaded from here:&lt;br /&gt;
&lt;iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-d95eb43c964b2b68.skydrive.live.com/embedrowdetail.aspx/.Public/ExchangeAudit.ps1" style="background-color: white; border: 1px solid rgb(221, 229, 233); height: 66px; margin: 3px; padding: 0pt; width: 240px;"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-485030117331444586?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/485030117331444586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/i-recently-needed-to-automate-my.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/485030117331444586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/485030117331444586'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/05/i-recently-needed-to-automate-my.html' title='Exchange WMI Audit'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-1852961649272147787</id><published>2009-04-17T08:59:00.021+02:00</published><updated>2009-10-28T15:23:01.035+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Update Network Interface Card parameters using WMI</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The following little function can be used if you need to manually override DNS and WINS addresses on a list of remote computers, where they may have already obtained addresses from a DHCP server. The code gets a list of IP enabled NICs from a remote computer using WMI, you can list the servers in servers.txt file in the same folder. The script updates your DNS servers search list to add two manual entries and also adds two manual WINS servers. I had some fun the SetWINSServer method as it only accepts the variable as an array. Finally, the script modifies the registry, to create a DNS suffix search list. Although this script only modifies limited parameters, it can easilly be adapted to update any of the other parameters.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;function updateNIC {
$NICs = gwmi -computer $server Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq “TRUE”}

foreach ($NIC in $NICs) {

$DNS=("1.1.1.1","2.2.2.2")
$WINS=@("1.1.1.1","2.2.2.2")
$DOMAIN="acme.com"

$NIC.SetDNSServerSearchOrder($DNS)
$NIC.SetDynamicDNSRegistration("TRUE")
$NIC.SetWINSServer($WINS[0],$WINS[1])
$NIC.SetDNSDomain($DOMAIN)

$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server)
$baseKey.OpenSubKey
$subKey=$baseKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",$true)
$subkey.SetValue('SearchList','acme.local,acme.com')

}
}
foreach($server in (gc .\servers.txt)){
updateNIC
}
&lt;/pre&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Here are some images of the results of the Advanced TCP/IP Settings page after running the script. Here is the WINS tab. &lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-1852961649272147787?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/1852961649272147787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/04/update-network-interface-card.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1852961649272147787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/1852961649272147787'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/04/update-network-interface-card.html' title='Update Network Interface Card parameters using WMI'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-8487835876231550416</id><published>2009-03-16T15:55:00.017+02:00</published><updated>2010-03-23T13:03:09.913+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='local groups'/><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='users'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Audit the local Administrators group on a list of remote computers</title><content type='html'>This is a very basic script which collects a list of server names from a local text file called servers.txt. The script reports the list of users, sorted by server name to a local text file in the root of drive C. I am working on cleaning up the results, as currently the "Adspath" reports to the text file in the following format: WinNT://DOMAIN/COMPUTER/Administrator This was the only true distinction between local or domain users, as "Name" reports only the name of the user or group. So you are never really sure if it is a domain or local entry. Finally I need to enable the script to report its results to Excel or HTML.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;$Result = @()

foreach($server in (gc .\servers.txt)){

$computer = [ADSI](”WinNT://” + $server + “,computer”)
$Group = $computer.psbase.children.find(”Administrators”)

function getAdmins
{$members = $Group.psbase.invoke(”Members”) | %{$_.GetType().InvokeMember(”Adspath”, ‘GetProperty’, $null, $_, $null)}
$members}

$Result += $server
$Result += ( getAdmins )
$Result += " "
}

$Result &amp;gt; c:\results.txt
Invoke-Item c:\results.txt
&lt;/pre&gt;&lt;br /&gt;
I had a little extra time today, and managed to clean up the members using the -replace parameter, replace "DOMAIN" with your domain name. The updated code looks something like this:&lt;br /&gt;
&lt;pre class="brush: powershell"&gt;$Result = @()

foreach($server in (gc .\servers.txt)){

$computer = [ADSI](”WinNT://” + $server + “,computer”)
$Group = $computer.psbase.children.find(”Administrators”)

function getAdmins
{$members = ($Group.psbase.invoke(”Members”) | %{$_.GetType().InvokeMember(”Adspath”, ‘GetProperty’, $null, $_, $null)}) -replace ('WinNT://DOMAIN/' + $server + '/'), '' -replace ('WinNT://DOMAIN/', 'DOMAIN\') -replace ('WinNT://', '')
$members}

$Result += Write-Output "SERVER: $server"
$Result += Write-Output ' '
$Result += ( getAdmins )
$Result += Write-Output '____________________________'
$Result += Write-Output ' '
}



$Result &amp;gt; c:\results.txt

Invoke-Item c:\results.txt
&lt;/pre&gt;You can simply add another -replace ('WinNT://DOMAIN/', 'DOMAIN\') for each domain in the system. I know its a little hack 'n slash but it will do for now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-8487835876231550416?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/8487835876231550416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/audit-local-administrators-group-on.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/8487835876231550416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/8487835876231550416'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/audit-local-administrators-group-on.html' title='Audit the local Administrators group on a list of remote computers'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-2044997156557494034</id><published>2009-03-11T14:50:00.016+02:00</published><updated>2009-10-28T15:20:23.949+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='users'/><category scheme='http://www.blogger.com/atom/ns#' term='folders'/><category scheme='http://www.blogger.com/atom/ns#' term='quest'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Automatically clean up orphaned user directories</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We've had a huge problem where users were removed from Active Directory, but somehow the administrators neglected to remove the home folder for the user from the file servers. This left someone with the nasty task of cleaning up the mess.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;This script will work through a directory of home folders and lookup the user in AD. This is assuming that the home folder and the user id are the same. If the user is not found, or the account is disabled, the folder will be renamed with a leading "orphan-" followed by the original name. The script requires a parameter, which is the path where the folders are located. e.g. "findorphans.ps1 c:\users" The script requires that the Quest Powershell Commandlets are installed, and they can be downloaded free, &lt;a href="http://www.quest.com/powershell/activeroles-server.aspx"&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;param($target)
$folders=Get-ChildItem -Path $target | Where-Object {$_.Name -notlike "orphan*" -and ($_.PSISContainer)} | Select-Object name
foreach ($folder in $folders){
Write-Host ""
$userid=""
"PROCESSING FOLDER: {0} "&amp;nbsp;&amp;nbsp; -f $folder.name
write-host "Searching for a possible owner..."
$user=Get-QADUser $folder.name
$useracc=$user.AccountIsDisabled
$userid=$user.samaccountname
$newid="orphan-" + $folder.name
$fullpath=$target + "\" + $folder.name
$fullpath
"Account Disabled: {0} "&amp;nbsp;&amp;nbsp; -f $user.AccountIsDisabled

if ($userid.length -lt "0" -or $user.AccountIsDisabled -eq "True") {
Write-Host "No owner found or account disabled, orphan folder renamed to" $newid -ForegroundColor Red
rename-Item -Path $fullpath -NewName $newid
}
else {
Write-Host "Owner found" $user -ForegroundColor Green
}
}
&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-2044997156557494034?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/2044997156557494034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/cleanup-orphaned-user-directories.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2044997156557494034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/2044997156557494034'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/cleanup-orphaned-user-directories.html' title='Automatically clean up orphaned user directories'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-8562841380190592271</id><published>2009-03-10T10:58:00.017+02:00</published><updated>2009-10-28T15:19:56.702+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='powershell'/><category scheme='http://www.blogger.com/atom/ns#' term='remote'/><category scheme='http://www.blogger.com/atom/ns#' term='defrag'/><category scheme='http://www.blogger.com/atom/ns#' term='wmi'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Remote Defrag using WMI</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This is a script I created to analyze and defrag Windows 2003 server volumes using the WMI win32_volume defrag method.&amp;nbsp; The script will collect all volumes on a list of remote servers using WMI. Each volume is then analyzed for fragmentation using the FilePercentFragmentation property. If the fragmentation property is higher than 10 the script will initiate a remote defrag on the volume.&amp;nbsp; You should see a process on the remote server called “dfrgntfs.exe” running while the defrag is in progress. Sadly I have not found a method to track the progress of the defrag process. You can adjust the fragmentation percentage threshold at which a defrag is initiated by editing line 12.&amp;nbsp; Replace "SERVER1" "SERVER2" with your server names. Comments or suggestions are always welcome.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class="brush: powershell" style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;$servers="SERVER1", "SERVER2"
foreach( $server in $servers){
Write-Host ""
$v=(gwmi win32_volume -computer $server)
"CURRENT SERVER: {0} " -f $server
"NUMBER VOLUMES: {0} " -f $v.length

foreach( $volume in $v){
Write-Host ""
write-host "Analyzing fragmentation on" ($volume.DriveLetter) "..."
$frag=($volume.defraganalysis().defraganalysis).FilePercentFragmentation
if ($frag -gt "10") {
write-host "Drive" ($volume.DriveLetter) "is currently" $frag "% fragmented." -foreground RED
write-host "Starting remote defrag..."
$volume.defrag($true)
}
else {
write-host "Drive" ($volume.DriveLetter) "is not fragmented" -foreground GREEN
Write-Host ""
}
}
}
&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-8562841380190592271?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://powershellneedfulthings.blogspot.com/feeds/8562841380190592271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/remote-wmi-defrag.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/8562841380190592271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/8562841380190592271'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2009/03/remote-wmi-defrag.html' title='Remote Defrag using WMI'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6646412165224764562.post-3014062090157202477</id><published>2008-01-01T12:00:00.000+02:00</published><updated>2009-10-29T12:46:09.163+02:00</updated><title type='text'>Subscribe</title><content type='html'>&lt;form style="border:1px solid #ccc;padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=PowershellNeedfulThings', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true"&gt;&lt;p&gt;Enter your email address:&lt;/p&gt;&lt;p&gt;&lt;input type="text" style="width:140px" name="email"/&gt;&lt;/p&gt;&lt;input type="hidden" value="PowershellNeedfulThings" name="uri"/&gt;&lt;input type="hidden" name="loc" value="en_US"/&gt;&lt;input type="submit" value="Subscribe" /&gt;&lt;p&gt;Delivered by &lt;a href="http://feedburner.google.com" target="_blank"&gt;FeedBurner&lt;/a&gt;&lt;/p&gt;&lt;/form&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6646412165224764562-3014062090157202477?l=powershellneedfulthings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3014062090157202477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6646412165224764562/posts/default/3014062090157202477'/><link rel='alternate' type='text/html' href='http://powershellneedfulthings.blogspot.com/2008/01/subscribe.html' title='Subscribe'/><author><name>Jean Louw</name><uri>http://www.blogger.com/profile/01226681112751547235</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
