Author Archives: Tommy Doan

About Tommy Doan


Find the top-level manager for any Active Directory user

I was recently asked to report on who the vice president is for a list of users. The PowerShell function below does that for the users who have a manager designated on their Active Directory account. It excludes the President … Continue reading

Posted in Uncategorized | Leave a comment

Compare the Exchange Alias to the Primary SMTP Address

Here’s a data quality report for an Exchange environment. This command looks for Alias values that do not match the “username” portion of the PrimarySMTPAddress values. Any discrepancies are returned. Get-Mailbox -ResultSize unlimited | where {$_.PrimarySmtpAddress.ToString() -notlike $_.Alias.ToString()+”@*”} | ft … Continue reading

Posted in PowerShell | 1 Comment

Search Active Directory for a list of email addresses

I’m occasionally asked to provide a list of account names based on a list of email addresses. This is pretty straight foward when the list of addresses contains only primary email addresses. Get-Content C:\scripts\users.txt | %{Get-ADUser -Filter {mail -like $_} … Continue reading

Posted in PowerShell | 1 Comment

Connecting to Office 365 with automation

In order to automate management activities for Office 365, it’s imperative to connect to the remote environments without human interaction. Typically this type of automated job will be run with Task Scheduler. However, due to differences between Windows authentication and … Continue reading

Posted in Office 365, PowerShell | Tagged | Leave a comment

compare two lists with PowerShell

I am asked occasionally to compare a list of employee ID numbers to find the differences or the matches. Notepad++ does not do a great job of this, so I put together a quick PowerShell solution. $dupes = @() [System.Collections.ArrayList]$arrA … Continue reading

Posted in PowerShell | 1 Comment

Office 365: removing Litigation Hold mailboxes in an Exchange Hybrid environment

In our hybrid Exchange 2010 / Exchange Online environment, we occasionally need to place an Exchange 2010 mailbox on Litigation Hold. In some cases, that user’s mailbox will need to be removed but the Active Directory account will need to … Continue reading

Posted in Office 365 | 2 Comments

Rotate images in ADFS 3.0

ADFS 3.0 is otherwise known as ADFS 2012 R2 since it is available only on Server 2012 R2. As I gain some experience with it, one of the nice configuration options is the ability to use PowerShell to customize the … Continue reading

Posted in Office 365, PowerShell | Tagged | Leave a comment

PowerShell error with Get-ADUser user -Properties *

After upgrading some of our servers to Server 2012 R2, we’ve discovered a bug in the PowerShell 4.0 Get-ADUser cmdlet. When running the command Get-ADUser username -Properties *, the cmdlet returns the following error: Get-ADUser : One or more properties … Continue reading

Posted in PowerShell | Tagged , | 3 Comments

SQL Server PowerShell Module (SQLPS)

SQL Server provides a Windows PowerShell module called sqlps that is used to import the SQL Server components into Windows PowerShell. The sqlps module loads two Windows PowerShell modules: A SQL Server provider, which enables a simple navigation mechanism similar … Continue reading

Posted in PowerShell | Tagged | 1 Comment

ActiveDirectory module and UAC

I have noticed a few odd behaviors with PowerShell’s ActiveDirectory module, one regarding the msDS-UserPasswordExpiryTimeComputed attribute of the Get-ADUser cmdlet, and another regarding the New-ADServiceAccount cmdlet. On a brand new Server 2008 R2 domain, the following command returns values for … Continue reading

Posted in PowerShell | Tagged , | 1 Comment