查找共享网络文件夹和 Active Directory 信息
我有一个脚本,用于尝试查找共享网络文件夹和子文件夹信息,例如文件夹所有者、与网络共享文件夹或子文件夹关联的 AD 组、AD 组注释、AD 组描述、AD 组管理器和 AD群组经理电子邮件。
我目前很难弄清楚为什么当我将其导出到 .csv 文件时没有显示任何数据。我将不胜感激任何帮助或指导。
# Find the owner of the Network Folders and the AD Groups they got access to and the details of those AD Groups (name, description, managedby and ema $FolderPath = $DomainName =
Start-Transcript $PSScriptRoot\Transcript.txt
$FolderPath = "\\server\foldername"
$DomainName = "Domain" # as in Domain\ADGroupName
write-Host "Getting All the permissions of a Folder and its subfolder..."
$ACLS = @()
$Acls += Get-Item $FolderPath | get-acl
$ACLs += Get-ChildItem $FolderPath -Recurse -Directory
$results = @()
foreach($acl in $acls)
{
$Domain = $DomainName.Split(".")[0]
write-Host " Getting Access ADGroup details"
$AllDomainAccess = $acl.Access | Where-Object { $_.identityReference -like "$Domain\*" }
foreach($DomainAccess in $AllDomainAccess)
{
$ADGroup = $null
$ADGroup = get-ADGroup $($DomainAccess.IdentityReference).value.split("\")[-1] -Properties * -server $DomainName -ea SilentlyContinue
if($null -ne $ADGroup)
{
$data = '' | Select-Object FolderPath, FolderOwner, AccessGroup, AccessGroup_Description, AccessGroup_ManagedBy, AccessGroup_ManagerEmail
$data.FolderPath = $acl.Path.split(":")[-1]
$data.FolderOwner = $acl.Owner
$data.AccessGroup = $ADGroup.Name
$data.AccessGroup_Description = $ADGroup.Description
$data.AccessGroup_ManagedBy = $ADGroup.ManagedBy
$data.AccessGroup_ManagerEmail = $(get-aduser $($ADGroup.ManagedBy) -Properties mail).mail
$results += $data
}
}
}
$results | export-csv "$PSScriptRoot\NetworkFolderPermissions.csv" -NoTypeInformation
write-Host "Saved the results in $PSScriptRoot\NetworkFolderPermissions.csv" -ForegroundColor Green
Stop-Transcript
I have a script that I'm using to try to find Shared network folder and subfolder information such as the folder owner, AD groups associated to the Network shared folder or subfolder, AD group notes, AD group description, AD group manager, and AD group manager email.
I'm currently having a hard time trying to figure out why none of this data is showing when I export this to a .csv file. I would appreciate any help or guidance.
# Find the owner of the Network Folders and the AD Groups they got access to and the details of those AD Groups (name, description, managedby and ema $FolderPath = $DomainName =
Start-Transcript $PSScriptRoot\Transcript.txt
$FolderPath = "\\server\foldername"
$DomainName = "Domain" # as in Domain\ADGroupName
write-Host "Getting All the permissions of a Folder and its subfolder..."
$ACLS = @()
$Acls += Get-Item $FolderPath | get-acl
$ACLs += Get-ChildItem $FolderPath -Recurse -Directory
$results = @()
foreach($acl in $acls)
{
$Domain = $DomainName.Split(".")[0]
write-Host " Getting Access ADGroup details"
$AllDomainAccess = $acl.Access | Where-Object { $_.identityReference -like "$Domain\*" }
foreach($DomainAccess in $AllDomainAccess)
{
$ADGroup = $null
$ADGroup = get-ADGroup $($DomainAccess.IdentityReference).value.split("\")[-1] -Properties * -server $DomainName -ea SilentlyContinue
if($null -ne $ADGroup)
{
$data = '' | Select-Object FolderPath, FolderOwner, AccessGroup, AccessGroup_Description, AccessGroup_ManagedBy, AccessGroup_ManagerEmail
$data.FolderPath = $acl.Path.split(":")[-1]
$data.FolderOwner = $acl.Owner
$data.AccessGroup = $ADGroup.Name
$data.AccessGroup_Description = $ADGroup.Description
$data.AccessGroup_ManagedBy = $ADGroup.ManagedBy
$data.AccessGroup_ManagerEmail = $(get-aduser $($ADGroup.ManagedBy) -Properties mail).mail
$results += $data
}
}
}
$results | export-csv "$PSScriptRoot\NetworkFolderPermissions.csv" -NoTypeInformation
write-Host "Saved the results in $PSScriptRoot\NetworkFolderPermissions.csv" -ForegroundColor Green
Stop-Transcript
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论