I am often asked how PowerShell can be used to set up test or lab Active Directory environments – and frankly could not come up with a single comprehensive answer – different people need different things in their labs.
Here’s what I do personally:
If I need to create a bunch of test accounts I just do something like:
1..20 | foreach-object { New-QADUser -Name "TestUser$_" -SamAccountName "TestUser$_" -ParentContainer mydomain.local/demo}
This creates accounts with no password set and disabled. If my demo needs enabled accounts I can just use the -UserPassword switch to set the password and Enable-QADUser to enable the accounts.
I often just use PowerGUI to randomly select a few users and set their City and/or Department. I guess I could do that with a pretty easy script randomly setting the values.
And then I can create groups and populating them by selected criteria, e.g.:
Get-QADUser -Department Sales | Add-QADGroupMember DL.Sales
There’s also a part of me telling that a better way would be to just create a CSV file instead and import the data:
Import-CSV c:\users.csv | ForEach-Object { New-QADUser -Name $_.Name -SamAccountName $_.Name -Department $_.Department -ParentContainer mydoman.local/demo }
Alternatively, one could user Get-QADUser (Get-QADObject, etc.) to retrieve data from a real domain, and re-create the data in a test environment. This obviously is a bad idea for external public demos but sounds like a good way to do test environments.
What are you doing for your test and demo environments? Any help/advice needed in doing what you want to do?
Tags: AD cmdlets, Active Directory, PowerGUI, PowerShell
Add to: | Technorati | Digg | del.icio.us | Yahoo | BlinkList | Spurl | reddit | Furl |
Like this:
Like Loading...