This is my first forum post. I’m extremely new to scripting in general as well as powershell. I apologize ahead of time if I don’t have the correct terminology or comprehension level needed for this.
We have multiple buildings where the naming convention for PCs is different per building. We perform a lot of inter-building moves and I would like to clean up computer names that have moved from one building to another.
What I’ve done so far:
I’ve ran this cmdlet in Powershell;
Get-ADComputer -Filter ‘Name -like “BTP”’ -Properties IPv4Address | FT Name,DNSHostName,IPv4Address -A | Out-File C:\New.Txt
So this generates a list of Computer Names, their DNS Host names (which I could technically omit) and their IP addresses;
BLBTP81 BLBTP81.domain.local 10.28.2.193
BLBTP80 BLBTP80.domain.local 10.27.1.17
I’ve also used the Export-CSV cmd, however I do not know how to separate the results with a comma so it puts all the data into a single column.
What I need help with:
I’ll take whatever suggestions anyone would like to give. What I’ve been trying to do is parse the text file that I’ve created with the cmdlet above, so that it filters out ONLY those computer names and IP addresses in which the 2nd octet is 27. So I could either remove all results that start with 10.28 or just parse out to a new text file those that start with 10.27
Again, I was going to just try to use the CSV file and sort/filter out what I needed, but then I’m not really using powershell to it’s full extent, nor do I know how to separate the results with a comma.
Thank you for your time!