PowerShell Dealing with Active Directory Latency


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 […]

Leave a comment

PowerShell v2 Gather remote software inventory


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 […]

1 Comment

PowerShell Find Date of a previous day in any week


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 […]

9 Comments

PowerShell Export-Csv with no header


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 […]

10 Comments

PowerShell Server Inventory Script


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 […]

2 Comments

Retrieve a list of stale Active-Sync devices


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 […]

11 Comments

PowerShell – Working with an Excel Range


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 “:” […]

Leave a comment

Use the –Filter, Luke


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 […]

Leave a comment

Get-DistributionGroupMember Recursively


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 […]

21 Comments

Script remote DCOM / WMI access for a non admin


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 […]

34 Comments

Design a site like this with WordPress.com
Get started