I'm a complete n00b, but I catch on pretty fast. However, I seeem to be running into a problem I could use some assistance with.
I currently use the following Powershell command to list the group membership of an individual user's computer so I can see which software package instances are associated to a computer.
(GET-ADComputer 'Computer1003' –Properties MemberOf | Select-Object MemberOf).MemberOf >c:outputfilescompgroupmembership.txt
Since it's only 1 machine, and I specified which one to look at, I know the retrieved groups are associated to that machine.
It seems to work okay for performing lookups for individual computers, but I want to pull a list of all machines in my OU and their associated groups.
I decided I'd try iterating through a TXT file that looks like the following:
Computer1003
Computer1004
Computer1005
Computer1006
Computer1007
Computer1008
I am trying to create the list of computer group membership so it appears like the following example:
Computer1003,Application1
Computer1003,Application3
Computer1003,Application7
Computer1004,Application1
Computer1004,Application2
Computer1004,Application3
Computer1004,Application6
If it's formatted like the above list, I can easily import it into MS Acces to pull reports for my supervisor.
I'm using the following command to iterate through the list of computers to get the groups to which they belong:
$computers = Get-Content c:inputfilescomputers.txt
Foreach($computer in $computers)
{ $computers + "is a member of: " + (Get-QADComputer -Id $computer).Memberof }
My output from the command is, well, not so good…
Basically, it looks like:
Computer1003
Computer1004
Computer1005
Computer1006
is a member of:
Application1
Application3
Application7
Computer1003
Computer1004
Computer1005
Computer1006
is a member of:
Application1
Application2
Application3
Application6
Technically, it's pulling the "proper" groups for each computer, but the output is listing all machines for each machine's group membership, and is only something I'd show to children if I were evil and wanted to give them nightmares.
Help, please?