Finding Service with Account Name Using Microsoft PowerShell V1.0

A few months back, I worked on a project where the customer needed to find all services on all servers that used a specific Active Directory (AD) account name. The problem was, they had no idea how the account name had been entered, nor did they know which server or what service used the account. I created a hard-coded script to search all computers in Active Directory for a partial account name. I finally made the time to make the script more useful and generic.

By default, the script requires an account name and will search all computers in AD that have “server” in the OperatingSystem property. The parameter, -AccountName, will have “*” added before and after the name. For example, entering “ctx” will cause the script to search all services for “*ctx*”. This will find [email protected], domain\svc_ctxaccount, and domain.tld\svc_ctxaccount.

Using -LiteralAccountName causes the script to use the account name entered exactly as typed. For example, -LiteralAccountName “[email protected]” will look for only that specific account name. The script will not search for domain\svc_ctxaccount or domain.tld\svc_ctxaccount.

By default, the script will search all computers in AD that have “server” in the OperatingSystem property. Use -ComputerName to restrict the search to a specific group of computers. For example, -ComputerName “pvs” will limit the search to only computers that have “pvs” somewhere in the DNSHostName property.

Using -InputFile allows you to create a text file containing computer name to search. The computer names can be NetBIOS or Fully Qualified Domain Name. The names contained in the file are not validated. Using -ComputerName will filter the names retrieved from the InputFile.

Using -OrganizationalUnit will restrict the search to computers contained in an OU tree. For example, -OrganizationalUnit “ou=RDS Servers,dc=domain,dc=tld” restricts the computers searched to all computers in that OU tree.

This script is in the Miscellaneous section of the downloads page.

You can always find the most current script by going to




About Carl Webster

Webster is a Sr. Solutions Architect for Choice Solutions, LLC and specializes in Citrix, Active Directory and Technical Documentation. Webster has been working with Citrix products for many years starting with Multi-User OS/2 in 1990.

View all posts by Carl Webster

No comments yet.

Leave a Reply