Have this code:
$Hosts = Get-ADComputer -Filter * -SearchBase "OU=Hosts,OU=Tier 2,DC=domain,DC=com"
foreach ($host in $Hosts ){Get-ADGroup $_ MemberOf }
…and wanted to see the computerName as well as all the group memberships
Have this code:
$Hosts = Get-ADComputer -Filter * -SearchBase "OU=Hosts,OU=Tier 2,DC=domain,DC=com"
foreach ($host in $Hosts ){Get-ADGroup $_ MemberOf }
…and wanted to see the computerName as well as all the group memberships
You already have it in the hosts variable. So you can write it out (Write-Host), add as a property to the current object (Add-Member), or create your own object with the desired properties (Select-Object w calculated properties or PSCustomObject)