Created
September 26, 2023 20:11
-
-
Save HiteaFR/36cac8778751d1d857e0fa780f56dc1d to your computer and use it in GitHub Desktop.
Créer des dossiers personnels dans un domaine avec Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OU_path = "OU_PATH" | |
$Base_Folder = "RUN_FOLDER" | |
$users = get-aduser -SearchBase $OU_path -filter * -Properties UserPrincipalName | % { $_.UserPrincipalName.Split('@')[0] } | |
$users | ForEach { | |
$folder = join-path -path $Base_Folder -childpath $_ | |
If (!(Test-Path -Path $folder )) { | |
New-Item -Path $folder -ItemType Directory | |
$acl = Get-Acl $folder | |
$acl.SetAccessRuleProtection($true, $true) | |
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($_, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow") | |
$acl.SetAccessRule($AccessRule) | |
$acl | Set-Acl $folder | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment