I am trying to create a PowerShell script that takes a list from an array of partial machine names and return them to me
So far, I've imported ActiveDirectory module and setup the array. I then run a foreach against the array but it doesn't return any results, instead going to a new line.
I have tried assigning the Get-ADComputer line to a variable and calling the variable. I have also tried to use the Return and not achieved my results.
The results can just print out in a list on the screen, that's OK. I just need it to return the results and then I can build up from that.
This is what I have done so far:
$getPC = @("7477", "7473", "7474")
foreach ($i in $getPC)
{
Get-ADComputer -filter {name -like "*$i*"} | select name
}
When I run the Get-ADComputer line alone, and put in the positional parameter, I have no problems. Any ideas?