[英]Pull each user's "Member Of" security group list from a text file
I written the below PowerShell script to pull the list security for each user.我编写了以下 PowerShell 脚本来为每个用户拉取列表安全性。 All user list are inside the text file "ulist.txt" line by line.
所有用户列表都在文本文件“ulist.txt”中逐行显示。 It not pull some user from that text file where as that really exist inside the directory.
它不会从该文本文件中提取某些用户,因为它确实存在于目录中。
Clear-Host
$ul = Get-Content -Path "C:\Users\username\Desktop\ulist.txt"
ForEach ($item in $ul){
$item = $item.toupper()
Write-Host ------------------------------------------------------------------ -ForegroundColor Yellow
Write-Host The user $item belongs to following security groups. -ForegroundColor Yellow
Write-Host ------------------------------------------------------------------ -ForegroundColor Yellow
$allgroups = Get-ADUser $item -Properties * | Get-ADPrincipalGroupMembership | Select-Object name | Format-Table -HideTableHeaders | Out-String | ForEach-Object { $_.Trim("`r","`n") }
$allgroups
Write-Host ------------------------------------------------------------------ -ForegroundColor Yellow
}
Error:错误:
Get-ADUser : Cannot find an object with identity: xxxxxxxx
Get-ADUser : Cannot validate argument on parameter 'Identity'.
The Identity property on the argument is null or empty.
I do not understand what is wrong in this script.我不明白这个脚本有什么问题。
It only pull and showing only the default group "Domain Users" for some users not the other groups associated.它只为某些用户拉取并显示默认组“Domain Users”,而不是其他相关组。
After modified a little bit when it was pulled and appended the user list, I did a little bit mistake.在拉取并附加用户列表时稍作修改后,我犯了一点错误。 Instead of "select Name", I changed it to "select SamAccountName".
我将其改为“选择 SamAccountName”,而不是“选择名称”。 Perfect, it displayed me what I was expecting.
完美,它向我展示了我的期望。
Thank you Team.谢谢团队。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.