Hi
Id like to automate the setting of folder permissions on folders during the PC build processI need for other users to ru the script and the default pc image will have powershell 1 and the executionpolicy will be the default restricted I need the users to simply click one file and not have to interact with powershell ISE.
This is a domain enviornment and I plan to have a bat file for the users to click and this will run the powershell script
bear in mind i will be setting security permissions on some root folders e.g. c:\root-folder
I am being plagued with errors and I cannot see them as powershell exits without my getting a chgnace to view them. i beleive there are problems with root folders and also Im not certain the script is being run with full rights
This script will be run under the restriced users account's so will/have run bat as different user / as admin
any advice? Thanks for reading
Bat file
start powershell.exe -executionpolicy unrestricted -file C:\Users\%username%\Desktop\set-folder-acl.ps1 -noexit
Powershell script
$currentuser=[Environment]::UserName
$Acl = Get-Acl "C:\Users\$currentuser\Desktop\test-psh"
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("everyone","FullControl","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "C:\Users\$currentuser\Desktop\test-psh" $Acl
confuseis