I have been using the following command to pull the list of membership for a given machinename:
Get-ADPrincipalGroupMembership -Identity (Get-ADComputer <MACHINENAME>)
| select-object name | Out-File C:mydirMemberShip.csv
The membership identifies software associated to a machine such as Adobe Acrobat Pro, MS Project, etc. Sometimes the software is associated but not actually installed which is why I use the query to validate this information against another list. I am trying to run a query to pull the membership for a list of assets in a text file and export with the name of each computer and the membership for each as well. Maybe get it to display something like the following:
NAME NAME
----------- -------------
<MACHINENAME1> ADOBE ACROBAT PRO
MS PROJECT STD
MS VISIO PRO
<MACHINENAME2> ADOBE ACROBAT PRO
ADOBE PHOTOSHOP
I have tried the following but I get a few errors:
$computers = Get-Content .computers.txt
Get-ADPrincipalGroupMembership ForEach ($computer in $computers)
{Get-ADComputer $computer} | select-object operatingSystem, name |
Out-Gridview
Any help or guidance would be greatly appreciated. Thank you.
2
Answers
You could do something like this. You could put it in a script, function or whatever.