How to Create AD User in Specific OU using Microsoft AD Spoke.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 08:47 PM - edited 10-13-2022 08:52 PM
Hi I'm creating the users in AD but i want to add the users in a specific OU for that i have added the powershell script as below which I have referred from community. but to create the input for OU the create user action was not editable, will it fine if we create a custom action for it or we can edit the oob?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 02:48 AM - edited 10-14-2022 09:39 PM
I faced similar kind of issue last time, I am still searching for some proper solution.
Fragomen Connect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2022 04:19 AM
Hi @Sravani36 ,
Can't you use the "Update AD Object OU" action after "Create User" action to put the user in the desired OU?
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 02:23 AM
Hi @Niklas Peterson,
Yeah, I have added it and also to customize the create user action for adding the other input as well like samaccountName, I have edited the powershell script for adding this SamAccountName and created the input in the flow but still the changes are not reflecting, the samaccount name is populating with the Sravani ch. Any idea how to fix this?
PowerShell script:
import-module activedirectory;
$SamAccountName = $SamAccountName -replace "%27","'";
$UserPrincipalName = $UserPrincipalName -replace "%27","'";
$DisplayName = $DisplayName -replace "%27","'";
$GivenName = $GivenName -replace "%27","'";
$Surname = $Surname -replace "%27","'";
$EmailAddress = $EmailAddress -replace "%27","'";
$MobilePhone = $MobilePhone -replace "%27","'";
$Title = $Title -replace "%27","'";
$Department = $Department -replace "%27","'";
$StreetAddress = $StreetAddress -replace "%27","'";
$City = $City -replace "%27","'";
$State = $State -replace "%27","'";
$Country = $Country -replace "%27","'";
$Password = $Password -replace "%27","'";
if($Password){
$pwrd = $Password | ConvertTo-SecureString -AsPlainText -Force
}
if ($UserPrincipalName.length -gt 20) {
Write-Host "Input length exceeded";
exit;
};
if($pwrd){
$enabled = $True;
New-ADUser -Name $DisplayName -AccountPassword $pwrd -DisplayName $DisplayName `
-GivenName $GivenName -SamAccountName $SamAccountName -Surname $Surname `
-EmailAddress $EmailAddress -UserPrincipalName $UserPrincipalName `
-MobilePhone $MobilePhone -Title $Title -Department $Department `
-Enabled $enabled -StreetAddress $StreetAddress -City $City `
-State $State -Country $Country -Credential $cred -Server $computer -PassThru;
}
else {
New-ADUser -Name $DisplayName -DisplayName $DisplayName -GivenName $GivenName`
-SamAccountName $SamAccountName -Surname $Surname -EmailAddress $EmailAddress`
-UserPrincipalName $UserPrincipalName -MobilePhone $MobilePhone -Title $Title`
-Department $Department -StreetAddress $StreetAddress -City $City`
-State $State -Country $Country -Credential $cred -Server $computer -PassThru;
}
sAMAccountName A-XXX(windows logon Name to update as this)
userPrincipalName A-xxx@gmail.com
displayName - Sravani ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 09:22 AM
Hi,
Sorry no. My suggestion was more to combine "Create User" and "Update AD Object OU" actions in the Flow to not have to do any powershell scripting.
Regards,
Niklas