Hello, Tek-Tips Chums
LTNS
I need to script the ADDITION of permissions to a folder, for a new hire's home drive. Not too difficult, I thought, and yes I suppose I COULD use iCacls, and I COULD import a module to do this, but I want to stick with built-in cmdlets.
I've gleaned this script from this Spiceworks thread but I've found that it replaces the default permissions (essentially the local Administrators group) with the new user's Modify permissions, rather than adding the new user's Modify permissions while leaving the existing permissions in place:
What are your thoughts?
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
LTNS
I need to script the ADDITION of permissions to a folder, for a new hire's home drive. Not too difficult, I thought, and yes I suppose I COULD use iCacls, and I COULD import a module to do this, but I want to stick with built-in cmdlets.
I've gleaned this script from this Spiceworks thread but I've found that it replaces the default permissions (essentially the local Administrators group) with the new user's Modify permissions, rather than adding the new user's Modify permissions while leaving the existing permissions in place:
Code:
$identity = $env:USERDNSDOMAIN + "\" + $SamAccountName
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule -argumentlist ($identity,"Modify","ContainerInherit, ObjectInherit","None","Allow")
# Get the current ACL from newly created folder
$homeDriveACL = Get-ACL $FullUNCPath
# Add the new Access Rule to the Current Rule
$homeDriveACL.AddAccessRule($accessRule)
# Set the new access rule on the new folder
Set-ACL -Path $FullUNCPath -ACLObject $homeDriveACL
What are your thoughts?
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]