Last active
June 29, 2020 05:00
-
-
Save technion/c44c79769d345513ee7215b93dd2e59d to your computer and use it in GitHub Desktop.
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
Set-StrictMode -Version 2 | |
Add-Type -AssemblyName 'System.Web' | |
$adusers = Get-ADGroupMember "Team" | |
foreach ($user in $adusers) { | |
$newname = "$($user.Samaccountname).delegate" | |
$password = [System.Web.Security.Membership]::GeneratePassword(12, 0) | |
$secPw = ConvertTo-SecureString -String $password -AsPlainText -Force | |
write-host "Creating delegate user $newname for account with password $password" | |
New-ADUser -Path "OU=stuff" ` | |
-AccountPassword $secPw -Name "$($user.Name) Full" -Enabled $true ` | |
-UserPrincipalName "$newname@au" -SamAccountName "$newname" | |
Get-ADUser $user | Set-ADUser -Add @{extensionAttribute13=$newname} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment