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
  • No, these accounts will be created in domain A as normal user provisioning and after that if answer to a question is yes user with same properties (samaccountname, firstname,lastname ...) will be created in domain B too (under entered credentials) in selected OU. Domain A and domain B do not "see" each other - they are in different forests and ARS is running on machine in domain A. Domain B can not even be added as managed domain. I know this idea might sound weird but I was given a task to do that. Currently there is a policy for user provisioning with many sub-policies (validation of user attributes, generating strong passwords, creating exchange mailbox ...) so I thought adding script execution policy which would call PS script doing what I mentioned was possible solution. As I said I have never worked with ARS before - PowerShell was my primary tool and GUI was not necessary.

Reply
  • No, these accounts will be created in domain A as normal user provisioning and after that if answer to a question is yes user with same properties (samaccountname, firstname,lastname ...) will be created in domain B too (under entered credentials) in selected OU. Domain A and domain B do not "see" each other - they are in different forests and ARS is running on machine in domain A. Domain B can not even be added as managed domain. I know this idea might sound weird but I was given a task to do that. Currently there is a policy for user provisioning with many sub-policies (validation of user attributes, generating strong passwords, creating exchange mailbox ...) so I thought adding script execution policy which would call PS script doing what I mentioned was possible solution. As I said I have never worked with ARS before - PowerShell was my primary tool and GUI was not necessary.

Children
No Data