【发布时间】:2021-09-05 09:27:10
【问题描述】:
#Cred= Get-Credential
$FolderPath = dir -Directory -Path "\\abc\dc\da" -Recurse -Force | where {$_.psiscontainer -eq $true}
$Report = @()
Foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
# $Name= Get-ChildItem $Folder -Recurse | where {!$_.PSIsContainer} |select-object fullname
foreach ($Access in $acl.Access)
{
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
Group or User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$Report += New-Object -TypeName PSObject -Property $Properties
}
}
$Report | Export-Csv -path "C:\Output\Test_16-06-2021.csv"
在上面的脚本中,我可以通过权限获取所有文件夹结构,但我想使用自定义参数,例如如果我只想使用 3 级文件夹,它应该得到如下输出
\\abc\a\b\c
\\abc\a\c\d
不喜欢
\\abc\a\b\c\d\text.txt
\\abc\a\c\d\e\f\g\demo.pdf
【问题讨论】:
-
请注意,这与typescript无关。我已经删除了那个标签。
标签: windows powershell powershell-4.0