22 Eylül 2020 Salı

Powershell New-Item

-Path seçeneği
Örnek
Şöyle yaparız
CMD Example: md testdirectory
Powershell Example: New-Item -Path "c:\" -Name "testdirectory" -ItemType "directory"
Örnek
Şöyle yaparız. Full control için kullanılacak parametreleri buradan aldım.
$directory = "..." $myuser="..." $denieduser="..." New-Item -Path $directory -ItemType Directory $acl = Get-Acl -Path $directory #Give full control to this folder,subfolders and files $rule = New-Object System.Security.AccessControl.FileSystemAccessRule ($myuser,"FullControl","ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) #Deny full control to another user $rule = New-Object System.Security.AccessControl.FileSystemAccessRule ($denieduser,"FullControl", "Deny") $acl.AddAccessRule($rule) #Set owner $owner=New-Object System.Security.Principal.NTAccount($myuser) $acl.SetOwner($owner) Set-Acl $directory $acl | Out-Null


Hiç yorum yok:

Yorum Gönder