PowerShell 递归查询组成员
function get-member{
)]
Param
(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
ValueFromPipeline=$true,
Position=0)]
$name
)
Begin
{
}
Process
{
$a=Get-DistributionGroupMember $name -ErrorAction SilentlyContinue
if($a -eq $null){
return
}
foreach($b in $a){
if (($b.Recipienttype -eq'Usermailbox') -or ($b.Recipienttype -eq 'MailContact') -or ($b.Recipienttype -eq 'User')){
write-host $b.name -ForegroundColor DarkYellow
}
else{
if($b.primarysmtpaddress -eq ""){
write-host $b.name -ForegroundColor red
}
else{
write-host $b.name -ForegroundColor Cyan
get-member $b.name
}
}
}
}
End
{
}
}
页:
[1]