Archive for category V2

PowerShell Get-Mailbox display SMTP addresses


A question was posed recently where a user wanted to see a list of all his mailboxes, with their server, primary SMTP address, and any additional SMTP addresses associated with the mailbox. The user specifically wanted ONLY SMTP addresses. With the help of a scriptblock, I was able to solve this on one line: 001 […]

98 Comments

My scripts will all be V2 from this point on.


PowerShell V2 has been available for all platforms since late October, 2009, so from now on all my scripts will be tested only on V2. I may post older scripts that work on V1, and in fact my new scripts may as well, but I won’t be testing them unless someone specifically asks for a […]

Leave a comment

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