Get Machines Name starting/ending with

This Scenario is mostly common when it comes to quick reports on Datacenter,department,floor,team etc.. Most of the organizations have naming convention to identify machine by the name with a specific set of letter in the name

For instance: MI-PDC-L2-R1-MGT01 this is a server name. To make it clear let me breakdown
MI = Melbourne
PDC = Primary Data Center
L2 = Level 2
R1 = Rack 1
MGT01 = Management Server 01

You can use the below script to find the machines that are in any of the above criteria

Get-ADComputer -Filter * | Where-Object {$_.Name -like “*machine name *”} | Select -Property Name,enabled 

To export it as a report

Get-ADComputer -Filter * | Where-Object {$_.Name -like "*machine name *"} | Select -Property Name,enabled >> "Output path.txt"

Published by iamfazul

Author of the site

Leave a comment