4 Pluspunkte 0 Minuspunkte

Wenn ich in Powershell diesen Befehl eingebe

Get-NTFSAccess \\fileserver\gbi\it-security

dann bekomme ich die selbe Ausgabe wie wenn ich die Berechtigungen im Explorer anzeige.

    Path: \\fileserver\gbi\it-security (Inheritance enabled)


Account                             Access Rights                       Applies to                Type                                IsInherited                        InheritedFrom                     
-------                             -------------                       ----------                ----                                -----------                        -------------                     
D2000\Security_Test                 FullControl                         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
NT-AUTORITÄT\SYSTEM                 FullControl                         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
D2000\Share_GBI_write               Modify, Synchronize                 ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
D2000\Share_GBI_read                ReadAndExecute, Synchronize         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
D2000\Domänen-Admins                FullControl                         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
D2000\named_admins                  FullControl                         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi                
VORDEFINIERT\Administratoren        FullControl                         ThisFolderSubfoldersAn... Allow                               True                               UNC\fileserver\gbi       

Wenn ich aber versuche die einzelnen Felder ausgeben will scheinen sich die Tabellennamen zu ändern.

$str = Get-NTFSAccess \\fileserver\gbi\it-security
foreach ($item in $str) {
    $account = $item.Account
    $accessRights = $item.AccessRights
    $appliesTo = $item.Appliesto
    $type = $item.Type
    $isInherited = $item.IsInherited
    $inheritedFrom = $item.InheritedFrom
    Write-Output "$($account);$($accessRights);$($appliesTo);$($type);$($isInherited);$($inheritedFrom)"
}

Die Felder AppliesTo und Type sind leer.

D2000\Security_Test;FullControl;;;True;UNC\fileserver\gbi
NT-AUTORITÄT\SYSTEM;FullControl;;;True;UNC\fileserver\gbi
D2000\Share_GBI_write;Modify, Synchronize;;;True;UNC\fileserver\gbi
D2000\Share_GBI_read;ReadAndExecute, Synchronize;;;True;UNC\fileserver\gbi
D2000\Domänen-Admins;FullControl;;;True;UNC\fileserver\gbi
D2000\named_admins;FullControl;;;True;UNC\fileserver\gbi
VORDEFINIERT\Administratoren;FullControl;;;True;UNC\fileserver\gbi
von  

3 Antworten

3 Pluspunkte 0 Minuspunkte

Im Sourcecode sieht man das das Feld dynamisch erzeugt wird.

[Security2.FileSystemSecurity2]::ConvertToApplyTo($_.InheritanceFlags, $_.PropagationFlags)

Du kannst eine Typerweiterung definieren um die Eigenschaft zum Objekt hinzuzufügen.

$Script = '[Security2.FileSystemSecurity2]::ConvertToApplyTo($this.InheritanceFlags, $this.PropagationFlags)'

$TypeData = @{
    TypeName   = 'Security2.FileSystemAccessRule2' 
    MemberName = 'AppliesTo'
    MemberType = 'ScriptProperty'
    Value      = [scriptblock]::Create($Script)
}

Update-TypeData @TypeData

Get-NTFSAccess \\fileserver\gbi\it-security | Select-Object Account, AccessRights, AppliesTo, AccessControlType
von (1.3k Punkte)  
2 Pluspunkte 0 Minuspunkte

Wenn du die member des Cmdlet anzeigst siehst du das es diese Felder nicht gibt.

Get-NTFSAccess \\fileserver\gbi\it-security | select-object * | Get-Member


   TypeName: Selected.Security2.FileSystemAccessRule2

Name               MemberType   Definition                                                       
----               ----------   ----------                                                       
Equals             Method       bool Equals(System.Object obj)                                   
GetHashCode        Method       int GetHashCode()                                                
GetType            Method       type GetType()                                                   
ToString           Method       string ToString()                                                
AccessControlType  NoteProperty AccessControlType AccessControlType=xxx                        
AccessRights       NoteProperty FileSystemRights2 AccessRights=xxx                      
Account            NoteProperty IdentityReference2 Account=xxx                   
AccountType        NoteProperty System.String AccountType=group                                  
FullName           NoteProperty string FullName=xxx                     
InheritanceEnabled NoteProperty bool InheritanceEnabled=True                                     
InheritanceFlags   NoteProperty InheritanceFlags InheritanceFlags=ContainerInherit, ObjectInherit
InheritedFrom      NoteProperty string InheritedFrom=xxx                          
IsInherited        NoteProperty bool IsInherited=True                                            
Name               NoteProperty string Name=xxx                                         
PropagationFlags   NoteProperty PropagationFlags PropagationFlags=None

Die Ausgabe wird wahrscheinlich aus InheritanceFlags und PropagationFlags abgeleitet.

von (1.1k Punkte)  
0 Pluspunkte 0 Minuspunkte
Danke für die codes big helper
von