Import-Module ActiveDirectory
Get-ADUser -SearchBase "OU=Users,DC=domain,DC=local" -Filter * | ForEach-Object {
Write-Host "User:" $_.Name -Foreground green
Get-ADPrincipalGroupMembership $_.SamAccountName | ForEach-Object {
Write-Host "Member Of:" $_.Name
}
}
我有一个脚本来获取用户所属的所有组。可以正常工作,但是我无法将其导出到* .csv文件。输出仅在PowerShell控制台中显示。有什么想法我必须添加到脚本中吗?