Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Two scripts combined

$
0
0

Hello all,

I have two commands that I would like to try and combine.  The first command is:

***********

 

Get-ADGroupMember"Name of your group" | ?{$_.ObjectClass -eq "Group"} | %{Write-Host $_.Name;Get-ADGroupMember $_ | ft name -HideTableHeaders}

************

What this command shows me is the group name and then the display name of the users within all of the directly nested groups.  IE:

 

NestedGroupName1

Anderson, Jake

Jean, Billie

 

NestedGroupName2

Schlama, dama

Bleh, meh

 

The second command is:

*************

 

$var = Read-host 'What is the Group Name?'; Get-ADGroupMember -Identity $var -server domain.com -Credential (Get-Credential -Credential domain\username) | Where-Object { $_.objectClass -eq 'user' } | Get-ADUser -Properties * | select SamAccountName,Description,Department

************

This lists all of the members of a group with the userID, Description, and Department.

 

What I would like is the recursive property of the first command with the detail from the second command.  Can this be done?


Viewing all articles
Browse latest Browse all 6937

Trending Articles