Alle Freigabe anzeigen:
|
1 |
Get-SmbShare |
Neue Freigabe erstellen:
|
1 |
New-SmbShare -Name HyperVFreigabe -Path C:\shares\Freigabe -FullAccess Jeder |
Freigabeberechtigungen anzeigen:
|
1 |
Get-SmbShareAccess -Name FreigabeName |
Freigabeberechtigungen für eine bestehende Freigabe ändern:
|
1 |
Grant-SmbShareAccess -Name FreigabeName -AccountName Jeder -AccessRight Read |
Freigabeberechtigungen auf NTFS-Berechtigungen spiegeln:
|
1 |
(Get-SmbShare -Name FreigabeName).PresetPathAcl | Set-Acl |
Changing the ACL
Okay, so you want to change the ACL. Here’s some sample code for how to do that:
|
1 2 3 4 5 |
New-Item -type directory -path C:\MyFolder $Acl = Get-Acl "C:\MyFolder" $Ar = New-Object system.security.accesscontrol.filesystemaccessrule("username","FullControl","Allow") $Acl.SetAccessRule($Ar) Set-Acl "C:\MyFolder" $Acl |
So, first we create a new folder. We then copy the ACL of that folder. We then create a new AccessRule that gives „username“ full control. We then add this AccessRule to the ACL, and finally we reapply the new, altered ACL to the folder.
If we wanted to we could also have used $Acl.RemoveAccessRule($Ar) or possibly $Acl.RemoveAccessRuleAll() as well.