AD Powershell命令:从特定用户获取嵌套组 [英] AD Powershell Command: Get Nested Groups from Specific User
问题描述
NEWBIE ALERT:我是一个非常新的PowerShell用户,我需要快速学习。但是,我需要运行一个查询来查找用户所属的组,以及嵌套组,以及循环嵌套组,我现在无法承受时间。我是
希望你能够帮助我...
我需要一个可以执行以下操作的脚本:
提示输入用户名,并提示输入特定组(如果有)。这就是我到目前为止:
$ user = Read-Host"请输入您想要检查的用户名"
$ group = Read-Host"请输入您要查找的群组"
if((Get-ADUser $ user -Properties memberof).memberof -like" CN = $ group *")
{
$ true
Write -Host((Get-ADUser $ user -Properties memberof).memberof -like" CN = $ group *")
}
Else
{
$ false
}
然而,我无法弄清楚如何获得一个漂亮的层次结构列表。它只会抛出组中的每个细节,如CN,OU,DC。所有我想要显示的结果是一个List,其中所有嵌套组都带有层次结构样式(缩进)输出。
这可以实现吗?提前感谢您的帮助......
Ben G。
这是一个起点:
http://ss64.com/ps/get-adprincipalgroupmembership.html
Get-ADPrincipalGroupMembership tester1 |
选择姓名
您需要为所需的输出做一些格式化工作。
NEWBIE ALERT: I am a very new PowerShell user, and I am in need to learn this fast. But, I need to run a query to find what groups a user is part of, but also the nested groups, as well as circular nested groups and I can't afford the time right now. I am hoping that you will be able to assist me...
I need a script that would do the following:
Prompt to enter the username, and prompt to enter a specific group (if any). This is what I have so far:
$user = Read-Host "Please enter the username you would like to check" $group = Read-Host "Please enter the group you looking for" if ((Get-ADUser $user -Properties memberof).memberof -like "CN=$group*") { $true Write-Host ((Get-ADUser $user -Properties memberof).memberof -like "CN=$group*") } Else { $false }
However, what I am can't figure out how to get a nice hierarchy list. It just throws up every detail from the group, like CN, OU, DC. All I want to be displayed as the outcome is a List with all the nested groups with a hierarchy-style (indents) output. Can this be achieved? Thank you in advance for the help...
Ben G.
Here's a starting point:
http://ss64.com/ps/get-adprincipalgroupmembership.html
Get-ADPrincipalGroupMembership tester1 | Select NameYou'll need to do some formatting work for your desired output though.
这篇关于AD Powershell命令:从特定用户获取嵌套组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!