Powershell script for SPO
Budget: £20 – £250 GBP
I need a PS script that can be given a SharePoint document library URL and then iterate through the subfolders, matching foldername=username and then setting the following permissions on that folder:
1. Break inheritance from above
2. Set folder owner to the matching username UPN
3. Set users manager UPN (from AAD) to be a contributor/editor of the folder
4. Set a security group to have contributor/editor access to the folder
5. Set a security group to have read access to the folder
6. If the user ac has been disabled then create a log file in the folder containing some details about the user from AAD
7. If the user ac was disabled more than 15 days ago remove all permissions, reset inheritance.
8. if the user ac was disabled more than 62 days ago move folder to be a subfolder of an Archived folder
Folders will be structured like this:
Shared%20Documents\Employees\A-F\{usernames}
Shared%20Documents\Employees\G-L\{usernames}
Shared%20Documents\Employees\M-R\{usernames}
Shared%20Documents\Employees\S-Z\{usernames}
Shared%20Documents\Employees\Archived\A-F\{usernames}
Shared%20Documents\Employees\Archived\G-L\{usernames}
Shared%20Documents\Employees\Archived\M-R\{usernames}
Shared%20Documents\Employees\Archived\S-Z\{usernames}
During testing the script will be run interactively, after testing it will be scheduled to execute weekly unattended so it must create comprehensive logs of what it is doing and recover gracefully showing the last attempted action, the error message obtained and the time before moving onto the next {username}folder.
I have previously used scripts like this on DFS hosted home folder shares, those folders are all gone now, and I need to replicate the same type of access and restrictions within a SharePoint document library.
I have no idea how to do much of this, so if it the brief above will not work please suggest reasonable changes.
1. Break inheritance from above
2. Set folder owner to the matching username UPN
3. Set users manager UPN (from AAD) to be a contributor/editor of the folder
4. Set a security group to have contributor/editor access to the folder
5. Set a security group to have read access to the folder
6. If the user ac has been disabled then create a log file in the folder containing some details about the user from AAD
7. If the user ac was disabled more than 15 days ago remove all permissions, reset inheritance.
8. if the user ac was disabled more than 62 days ago move folder to be a subfolder of an Archived folder
Folders will be structured like this:
Shared%20Documents\Employees\A-F\{usernames}
Shared%20Documents\Employees\G-L\{usernames}
Shared%20Documents\Employees\M-R\{usernames}
Shared%20Documents\Employees\S-Z\{usernames}
Shared%20Documents\Employees\Archived\A-F\{usernames}
Shared%20Documents\Employees\Archived\G-L\{usernames}
Shared%20Documents\Employees\Archived\M-R\{usernames}
Shared%20Documents\Employees\Archived\S-Z\{usernames}
During testing the script will be run interactively, after testing it will be scheduled to execute weekly unattended so it must create comprehensive logs of what it is doing and recover gracefully showing the last attempted action, the error message obtained and the time before moving onto the next {username}folder.
I have previously used scripts like this on DFS hosted home folder shares, those folders are all gone now, and I need to replicate the same type of access and restrictions within a SharePoint document library.
I have no idea how to do much of this, so if it the brief above will not work please suggest reasonable changes.