This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARS 6.9 Script Execution Policy

Hi, I have ARS 6.9 and I need to add script execution policy to current policy which does the following:

  • Displays dialog box with Yes/No question (Create an user account in domain B?)
  • If answer to question is Yes
    • displays dialog box to enter credentials for other domain B
    • displays form from which user selects appropriate OU in domain B
    • creates user account and puts it into selected OU in domain B

NOTE: Current policy creates new user account in domain A and goal of adding script execution policy as last step is the following: If answer to question is Yes user with the same First Name, Last Name, SamAccountName, Display Name will be created in domain B using entered credentials with required permissions.

For some reason script module below has not been executed. Is ARS capable of executing scripts which deal with GUI elements? Also here I have implemented dot source technique since Choose-ADOrganizationalUnit function is inside C:\script\ChooseADOrganizationalUnit.ps1 script. I am very familiar with PowerShell but newbie in ARS.

 

function onPostCreate($Request)
{
Import-Module ActiveDirectory
Add-Type -AssemblyName PresentationFramework
Add-PSSnapin Quest.ActiveRoles.ADManagement
Connect-QADService -Proxy

$dn=$DirObj.Get(“distinguishedName”)

$givenName=Get-QADUser $dn | Select-Object -ExpandProperty FirstName
$surName=Get-QADUser $dn | Select-Object -ExpandProperty LastName
$samAccountName=Get-QADUser $dn | Select-Object -ExpandProperty SamAccountName
$name=Get-QADUser $dn | Select-Object -ExpandProperty Name
$displayName=Get-QADUser $dn | Select-Object -ExpandProperty DisplayName
#$userPrincipalName=Get-QADUser $dn | Select-Object -ExpandProperty UserPrincipalName


$toCreateUserinDSC = [System.Windows.MessageBox]::Show('Would you like to create a user in B domain?','New User','YesNo','question')

if($toCreateUserinDSC -eq "Yes") {
$cred=Get-Credential
. "C:\script\ChooseADOrganizationalUnit.ps1"
$ou=Choose-ADOrganizationalUnit -HideNewOUFeature
New-ADUser -GivenName $givenName `
-Surname $surName `
-SamAccountName $samAccountName `
#-Description $user.Description `
-Path $ou.DistinguishedName `
-Name $name `
-DisplayName $displayName `
-UserPrincipalName ($samAccountName + '@domainB.local') `
-AccountPassword (ConvertTo-SecureString -AsPlainText (-join (33..126 | ForEach-Object {[char]$_} | Get-Random -Count 10)) -Force) `
-Enabled $true `
-ChangePasswordAtLogon $true '
-Server dc1.domainB.local '
-Credential $cred
}
}

Parents
  • To make Domain B manageable, you need the same ports open as you would need to be able to use ADUC against it.

    Plus, you would need an account to configure as the "override account" on the Managed Domain. This account would need to be able to read the contents of the domain and in your case, create users.

    Once you get it in place as a managed domain, the OU selection is simple - you can browse the domain and create the user by starting the creation in the right OU.

    Otherwise, you could use another virtual attribute to add to the user creation Wizard - maybe call it edsva_Target_OU In this case, if you specify the "syntax" of that virtual attribute to be a distinguishedname, you get searching for an OU "for free" from Active Roles.
Reply
  • To make Domain B manageable, you need the same ports open as you would need to be able to use ADUC against it.

    Plus, you would need an account to configure as the "override account" on the Managed Domain. This account would need to be able to read the contents of the domain and in your case, create users.

    Once you get it in place as a managed domain, the OU selection is simple - you can browse the domain and create the user by starting the creation in the right OU.

    Otherwise, you could use another virtual attribute to add to the user creation Wizard - maybe call it edsva_Target_OU In this case, if you specify the "syntax" of that virtual attribute to be a distinguishedname, you get searching for an OU "for free" from Active Roles.
Children
No Data