I want to extract a folder and its sub folders permission details.
My server is Windows 2008, I use Windows PowerShell script but getting below error.
Get-ChildItem : A parameter cannot be found that matches parameter name 'Directory'. At line:1 char:5 + dir -Directory -Path "H:\RMSRE7\RMS1" -Recurse -Force + ~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
PowerShell script:
$FolderPath = dir -Directory -Path "\\H:\RMSRE7" -Recurse -Force
$Report = @()
foreach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.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 "D:\Public\RE7_FolderPermissions.csv"
-Directory
and-File
are not part of the filesystem provider in early versions - not sure exactly when they were introduced, but probably v3. – boxdog