PowerShell Dealing with Active Directory Latency
Posted by Karl Mitschke in 2007, Exchange, PowerShell, V1, V2 on January 8, 2010
Consider the following: 001 002 003 004 005 006 007 New-DistributionGroup -Name "karls test group" ` -SamAccountName "karlstestgroup" ` -DisplayName "Karls Test" ` -Type "Security" ` -OrganizationalUnit "contoso.com/Test/EmailTest" Add-DistributionGroupMember ` -Identity "karlstestgroup" -Member "karlmitschke@contoso.com" If you have latency in your Active Directory, you most likely will get an error on the “Add-DistributionGroupMember” command: Add-DistributionGroupMember : The operation could not be performed because ‘karlstestgroup’ could not be found. Note that […]
PowerShell v2 Gather remote software inventory
Posted by Karl Mitschke in PowerShell, V2 on December 23, 2009
I was recently asked to gather information on every Adobe product installed on 576 Windows servers. I thought this would be no problem, because I could use Get-WmiObject with the Win32_Product Class and go home early. Alas, it was not to be: Per the WMI blog (http://blogs.msdn.com/wmi/default.aspx), Windows Server 2003 doesn’t have the Win32_Product Class […]
PowerShell Find Date of a previous day in any week
Posted by Karl Mitschke in PowerShell, V1, V2 on December 19, 2009
I often need to name a file with a date as part of the file name like: ServerInventory12-18-2009.csv A simple $date = $(get-date).ToString(“MM-dd-yyyy”) works great for today, but I recently had a need to create a file once a week, with a file name of the previous Saturday. I had come across Arul Kumaravel’s WebLog […]
PowerShell Export-Csv with no header
Posted by Karl Mitschke in PowerShell, V2 on December 15, 2009
I’m working on a project that provides billing information on 1 specific service – Lyris ListManager messages sent by company (Or in ListManager parlance, site) I had all the data, and exported it to a csv as that was the format that we agreed to provide to the billing people. Life was good for about […]
PowerShell Server Inventory Script
Posted by Karl Mitschke in PowerShell, WMI on December 10, 2009
I was asked for my Server Inventory script on the newsgroup Microsoft.Public.Windows.PowerShell. This is my script, in a slightly compressed and sanitized version – Compressed as I stripped out Novell, Unix, and ESX Host logic, sanitized in that I don’t really have a domain contoso.com 😉 After the script, if you stick around, I will […]
Retrieve a list of stale Active-Sync devices
Posted by Karl Mitschke in 2007, Exchange, PowerShell, V1 on December 4, 2009
We allow users who have signed the proper policy to access their Exchange mailbox via Active Sync devices. Users being users, though, we quite often have active sync devices that are registered to a mailbox, but are no longer in use. Users always have a clever excuse like “Oh, i lost that last year”, or […]
PowerShell – Working with an Excel Range
Posted by Karl Mitschke in PowerShell on November 27, 2009
I’m working on a server inventory project, and as part of that project, I need to add a field “Monitored” – this field will show either SCOM, Nimbus, No, or N/A. N/A will mean the server has an exception to monitoring. These servers are in a text file called NonmonitoredServers.txt: Server098 PRDServer198:PRDServer598 TestServer011:TestServer055 The “:” […]
Use the –Filter, Luke
Posted by Karl Mitschke in Exchange, PowerShell on November 25, 2009
Quite often, I see questions like “Why is my Get-Recipient command so slow?”, with a syntax like: 001 002 003 $user1 = Get-Recipient -ResultSize unlimited ` |Where-Object {$_.emailaddresses -eq ` ‘karlmitschke@contoso.com’} You would think that would work lickity split, because there is only 1 result, me. Ah, not so fast, grasshopper. We are doing client side filtering – all recipients are returned by […]
Get-DistributionGroupMember Recursively
Posted by Karl Mitschke in Exchange, PowerShell on November 24, 2009
I had a need to get distribution group members for a specific group. Most people seem to install the free “ActiveRoles Management Shell for Active Directory” from Quest Software when they are facing a task such as this. With the Quest “ActiveRoles Management Shell”, you can do this like “Get-QadGroupMember <group name>–Indirect” I’m kind of […]
Script remote DCOM / WMI access for a non admin
Posted by Karl Mitschke in DCOM, PowerShell, WMI on November 20, 2009
Recently I was asked to create an inventory process that would query active directory for servers and gather data on their hardware. I said “No problem”, fired up my trusty domain admin account and ran a bunch of WMI calls against the servers. Of course, for a script that is to be run on a […]


