Need help getting displayname for group as well as groupmember to show up with out-gridview. I must be missing something simple
#===============================================================================================================#
# This section will open a window with the AD Structure listed. Select the OU you want to target
#===============================================================================================================#
$GetADOU=Get-ADOrganizationalUnit-Filter*-properties* | Select canonicalname,DistinguishedName | sort-object canonicalname | Out-GridView-Title"Pick an OU"-passthru
$ADOU=$GetADOU.distinguishedname
$ADOU
#===============================================================================================================#
# This section will open a window into the OU selected. Select the Group you want to target
#===============================================================================================================#
$GetADGroup=Get-ADgroup-Filter*-searchbase$ADOU | Select name,displayname | sort-object name | Out-GridView-Title"Pick a Group"-passthru
$Group=$GetADGroup.name
$Group
#===============================================================================================================#
# This section will open a window with the group members listed. Select the the names to remove
#===============================================================================================================#
$GetADGroupMember=Get-ADGroupMember$Group | Select displayname,samaccountname | sort-object displayname | Out-GridView-Title"Pick Users"-passthru
$ADGroupMember=$GetADGroupMember.samaccountname
$ADGroupMember
#===============================================================================================================#
# After selecting everything you need, run the "RemoveFromGroup" function below by typing it into the powershell
# console window
#===============================================================================================================#
Function RemoveFromGroup {
Begin{}
Process{Remove-ADGroupMember-Identity$group-Members$ADGroupMember-confirm:$false
write-host ($ADGroupMember+" removed from "+$group)}
End{}
}
# This section will open a window with the AD Structure listed. Select the OU you want to target
#===============================================================================================================#
$GetADOU=Get-ADOrganizationalUnit-Filter*-properties* | Select canonicalname,DistinguishedName | sort-object canonicalname | Out-GridView-Title"Pick an OU"-passthru
$ADOU=$GetADOU.distinguishedname
$ADOU
#===============================================================================================================#
# This section will open a window into the OU selected. Select the Group you want to target
#===============================================================================================================#
$GetADGroup=Get-ADgroup-Filter*-searchbase$ADOU | Select name,displayname | sort-object name | Out-GridView-Title"Pick a Group"-passthru
$Group=$GetADGroup.name
$Group
#===============================================================================================================#
# This section will open a window with the group members listed. Select the the names to remove
#===============================================================================================================#
$GetADGroupMember=Get-ADGroupMember$Group | Select displayname,samaccountname | sort-object displayname | Out-GridView-Title"Pick Users"-passthru
$ADGroupMember=$GetADGroupMember.samaccountname
$ADGroupMember
#===============================================================================================================#
# After selecting everything you need, run the "RemoveFromGroup" function below by typing it into the powershell
# console window
#===============================================================================================================#
Function RemoveFromGroup {
Begin{}
Process{Remove-ADGroupMember-Identity$group-Members$ADGroupMember-confirm:$false
write-host ($ADGroupMember+" removed from "+$group)}
End{}
}