pablo007 Posted March 2, 2018 Posted March 2, 2018 Hi all I want to create a powershell script to run during my mdt task sequence that will A. rename a local folder called 'test folder' and rename it to the local machine name b share that newly renamed folder as is its computer name c. give full permissions to a group called itadmins this is what I have so far Rename-Item "c:\test folder" $env:computername Get-ChildItem Env:COMPUTERNAME | select -exp value New-SMBShare –Name value –Path “C:\Env:COMPUTERNAME” ` –ContinuouslyAvailable ` –FullAccess domain\itadmin ` So part A works ok but part B and thus part C do not, I know that this Get-ChildItem Env:COMPUTERNAME | select -exp value returns the machine name so I need to know how to then use that later to create the share and set the permissions complete powershell noob but giving it a go and as always any help gratefully received. thanks
Rob_D Posted March 2, 2018 Posted March 2, 2018 Have you looked at this? https://sharepoint.stackexchange.com/questions/133843/how-to-create-a-shared-folder-using-powershell-and-set-permissions NET SHARE $env:computername=C:\$env:computername /GRANT:ITUsers,FULL This works fine for me as long as I'm running powershell elevated. 1
pablo007 Posted March 2, 2018 Author Posted March 2, 2018 thanks this set me on the right path cmd /c $("NET SHARE $env:computername=C:\$env:computername /GRANT:""ITadmin,FULL") works
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now