You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on creating some training labs for my colleagues. One part of the lab is to install a Domain Controller then create some pre-defined users/groups/OUs. I have this functioning as I would like aside from the password on the accounts.
When I start my lab build script, it checks to see if $env:LAB_ADMIN_PASS is defined. This is the password used for all accounts created by AL. When using it in the Add-LabDomainDefinition or Set-LabInstallationCredential cmdlets it works beautifully. The issue I have is if I try to use a variable of any sort in my PostInstallationActivity.
I have the script in $labSources/CustomRoles/PrepareDomain/PrepareDomain.ps1. I define a hashtable of User, Group, and OU data and then loop thru each to create each object. For my user creation I have gotten it to work with this loop in my script:
Note that in the Set-ADAccountPassword cmdlet, that I have the password statically defined. I would much rather take this out of my hands and leave it in the hands of whoever is creating the lab so they can have a sensibly defined password that they will know. I attempted to substitute the static password for $args[0] and add -ArgumentList $env:LAB_ADMIN_PASS to my Invoke-LabCommand call for this activity. If I do this, none of my users get created despite the password not even being used in the New-ADUser cmdlet.
I feel like I'm just missing something but I'm not 100% sure on what that is.
I was originally looking to use DSC for this, but could not get it to reliably work. This could be a skill issue as my background is not Windows and PS based, but more Linux based.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm working on creating some training labs for my colleagues. One part of the lab is to install a Domain Controller then create some pre-defined users/groups/OUs. I have this functioning as I would like aside from the password on the accounts.
When I start my lab build script, it checks to see if $env:LAB_ADMIN_PASS is defined. This is the password used for all accounts created by AL. When using it in the
Add-LabDomainDefinition
orSet-LabInstallationCredential
cmdlets it works beautifully. The issue I have is if I try to use a variable of any sort in my PostInstallationActivity.I have the script in
$labSources/CustomRoles/PrepareDomain/PrepareDomain.ps1
. I define a hashtable of User, Group, and OU data and then loop thru each to create each object. For my user creation I have gotten it to work with this loop in my script:Note that in the
Set-ADAccountPassword
cmdlet, that I have the password statically defined. I would much rather take this out of my hands and leave it in the hands of whoever is creating the lab so they can have a sensibly defined password that they will know. I attempted to substitute the static password for$args[0]
and add-ArgumentList $env:LAB_ADMIN_PASS
to myInvoke-LabCommand
call for this activity. If I do this, none of my users get created despite the password not even being used in theNew-ADUser
cmdlet.I feel like I'm just missing something but I'm not 100% sure on what that is.
I was originally looking to use DSC for this, but could not get it to reliably work. This could be a skill issue as my background is not Windows and PS based, but more Linux based.
Thanks for any help!
Beta Was this translation helpful? Give feedback.
All reactions