简体   繁体   English

需要以下 AD 脚本的指导

[英]Need guidance with the below AD Script

I'm having issues trying to pull the members of the security tab of each group in AD.....can someone help pls?我在尝试拉出 AD 中每个组的安全选项卡的成员时遇到问题......有人可以帮忙吗?

Get-ADGroup -filter * -Properties name, security | select security, @{n=’Security’; e= { ( $_.Security | % { (Get-ADObject $_).Name }) -join “,” }}

Error below:错误如下:

Get-ADGroup : One or more properties are invalid.
Parameter name: security
At line:1 char:1
+ Get-ADGroup -filter * -Properties security | select security, @{n=’Se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ADGroup], ArgumentException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADGroup

What am I missing here?我在这里错过了什么?

You can use the Get-Acl cmdlet in conjunction with the AD provider.您可以将Get-Acl cmdlet 与 AD 提供程序结合使用。 If you're getting all of your groups, you must be using the ActiveDirectory module, so you should have the provider available as well.如果您要获取所有组,则必须使用 ActiveDirectory 模块,因此您也应该有可用的提供程序。 The provider allows you to browse through Active Directory similarly to a file system.该提供程序允许您像浏览文件系统一样浏览 Active Directory。 So first thing to do is swap to that provider:因此,首先要做的是切换到该提供商:

cd AD:

Then you can get your groups like you intended to:然后你可以像你想要的那样得到你的组:

$Groups = Get-ADGroup -filter *

Now you can loop through those and use the distinguishedName to get the ACLs for each group object. Now, there's a few ways to do this, I'm going to use Add-Member .现在您可以遍历这些并使用 distinguishedName 获取每个组 object 的 ACL。现在,有几种方法可以做到这一点,我将使用Add-Member AD Group objects like to try and make any new members ADPropertySets, so we'll be using the -force parameter to make sure it is a NoteProperty. AD Group 对象喜欢尝试创建任何新成员 ADPropertySets,因此我们将使用-force参数来确保它是一个 NoteProperty。

$Groups | ForEach-Object{
    $ACLs = Get-Acl -Path $_.distinguishedName
    Add-Member -InputObject $_ -NotePropertyName 'Security' -NotePropertyValue $ACL.Access -Force
}

Then you can just do something like $Groups|Format-Table Name,Security or something.然后你可以做一些类似$Groups|Format-Table Name,Security类的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM