Hi All,
I work for a company that get anywhere between 30-60 onboardings a month.
To make life easier over the past 6 months been trying to create a script which completes the following once the AD user object exists.
Inputting the users name displays their
DisplayName, sAMAccountName,Country,Company,Title,Office and then automatically move the account based on the listed office property.
understand ill need some sort of array or database where i can match the office property against but not entirely sure how to do this.
$title = "New User Set up
"
$title
$UserName = Read-Host -Prompt "Enter the Username "
Get-ADUser -Identity $UserName -Properties * | Select-Object DisplayName, sAMAccountName,Country,Company,Title,Office | FL
$OfficeLocation = Get-ADUser -Identity $UserName -Properties * | Select-Object Office
the 1.0 version of this script i manually type in the the name of the location but with the entirety of emea under me it seems more reasonable to create the location ou then once the officelocation is picked up by the script match it in the array and move based on that.
$OUs = @{
Birmingham="OU=Birmingham ,OU=United Kingdom,OU=EMEA,OU=xxx - Users,DC=xxxx,DC=xxxx,DC=com";
London="OU=London ,OU=United Kingdom,OU=EMEA,OU=xxx - Users,DC=xxxx,DC=xxxx,DC=com";
}
$ShowOU = New-Object System.Management.Automation.Host.ChoiceDescription "&1" ,"Show list of available OUs"
$options = [system.Management.Automation.host.choicedescription[]]($ShowOU)
$result2 = $host.ui.PromptForChoice($title2, $message, $options, 0)
switch ($result2) {
0 { $OUs | Format-Table -AutoSize -Property Name }
}
Any help appreciated.