Partager via


Creating Lab Computer Objects

So I’m getting my preparation done for TechEd 2013 on the Gold Coast and needed to fill my ConfigMgr hierarchy with some dummy computer objects. My session being PowerShell for ConfigMgr 2012 SP1, of course I went straight to PowerShell to do the work for me. 

I’m not looking for anything too special; 1000 laptops, 1000 desktops and 500 servers for my demo domain contoso.com.

ConfigMgr can be a little picky when it comes to AD System Discovery, such as requiring a matching DNS record and a valid Operating System value. All of the options below are required otherwise you get errors in the ADSysDis.log.

 

Here’s my script (note: you must have the Active Directory PowerShell module installed on the local machine)

 

Import-Module ActiveDirectory
$Count=1
$LaptopCount = 1001
$DesktopCount = 1001
$ServerCount = 501
# Create Laptops
While ($Count -lt $LaptopCount)
{
New-ADComputer -Name "CON-LAP-$Count" -DNSHostName "CON-LAP-$Count.contoso.com" -OperatingSystem "Windows 7 Enterprise" -OperatingSystemVersion "6.1 (7600)"
Add-DnsServerResourceRecord -ZoneName contoso.com -Name "CON-LAP-$Count" -IPv4Address "192.168.169.123" -A
$Count = $Count + 1
}
$Count = 1
# Create Desktops
While ($Count -lt $DesktopCount)
{
New-ADComputer -Name "CON-DSK-$Count" -DNSHostName "CON-DSK-$Count.contoso.com" -OperatingSystem "Windows 7 Enterprise" -OperatingSystemVersion "6.1 (7600)"
Add-DnsServerResourceRecord -ZoneName contoso.com -Name "CON-DSK-$Count" -IPv4Address "192.168.169.123" -A
$Count = $Count + 1
}
$Count = 1
# Create Servers
While ($Count -lt $ServerCount)
{
New-ADComputer -Name "CON-SVR-$Count" -DNSHostName "CON-SVR-$Count.contoso.com" -OperatingSystem "Windows Server 2012 Enterprise" -OperatingSystemVersion "6.2 (9200)"
Add-DnsServerResourceRecord -ZoneName contoso.com -Name "CON-SVR-$Count" -IPv4Address "192.168.169.123" -A
$Count = $Count + 1
}

Active Directory Computer accounts

image

DNS A Records

image

Matt Shadbolt

Comments

  • Anonymous
    January 01, 2003
    Excellent