creating Xtemp and Ytemp temporary folders with user permissions

Need assistance with a Powershell script for automatically creating Xtemp and Ytemp temporary folders
The folders to be created have the following path

The users should have write access within these folders

Looking to create a powershell script that takes the username as an input parameter, and executes the following file system operations
-Create the user-folder \contoso.local\home\homeshare<username>

-Disable inheritance at the level \contoso.local\home\homeshare<username> and convert all inherited file system permissions to explicit permissions

-Change owner to

-Give the following groups Full Control:



-Give the Read & Execute Permissions

-Remove all other permissions from the folder

-Create the folder called “home” within the folder

-Create the XTemp folders \contoso.local\home\homeshare<username>\home\Xtemp\Xtemparchive

-Create the Ytemp folders \contoso.local\home\homeshare<username>\home\Ytemp

Add Modify-permissions for at the level \contoso.local\home\homeshares<username>\Home\Xtemp\

-Add Modify-permissions for at the level \contoso.local\home\homeshare<username>\home\Ytemp

Welcome to the forum. :wave:t4:

What kind of help do you need?

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

What have you tried so far? We expect you to make an own attempt to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in <---- Click :point_up_2:t4: :wink:

1 Like