Weekly Tip 58

You can use this script to mass create sequentially named computer objects in AD. This is helpful if you pre-stage object before imaging, and they are all named with a common scheme. This script requires the AD PowerShell module. The first variable ($number) should be one less than the starting number, meaning that if your first machine is ABC-01, this variable should equal zero. Second, input your naming scheme on the line that starts with $name. Change the OU path on the new-adcomputer line to reflect the location where the objects should be created. Finally, change the “Until” line to be the last machine, meaning that if I want 1 – 25 created, I would make this line ABC-25.

Import-Module activedirectory

$number = 0

Do {
$number = $number + 1
If ($number -lt 10) {$name = “ABC-0” + “$number”} Else {$name = “ABC-” + “$number”}
new-adcomputer -name $name -SAMAccountName $name -path “ou=accounting,ou=computers,dc=contoso,dc=com”
write-host “created $name”
} Until ($name -eq “ABC-25”)



Contact Us

On Key

More Posts

Mastering Azure AD Connect - A Comprehensive Guide by WME
Active Directory

Mastering Azure AD Connect – A Comprehensive Guide

Modern businesses are fast moving toward cloud-based infrastructure. In fact, cloud-based business is not just a trend anymore but a strategic necessity. Microsoft’s Azure Active Directory (Azure AD) has become a frontrunner in this domain. It

Read More »
Security Best Practices in SharePoint
Office 365

Security Best Practices in SharePoint

Microsoft SharePoint is an online collaboration platform that integrates with Microsoft Office. You can use it to store, organize, share, and access information online. SharePoint enables collaboration and content management and ultimately allows your teams to

Read More »
The Ultimate Guide to Microsoft Intune - Article by WME
Active Directory

The Ultimate Guide to Microsoft Intune

The corporate world is evolving fast. And with that, mobile devices are spreading everywhere. As we venture into the year 2024, they have already claimed a substantial 55% share of the total corporate device ecosystem. You

Read More »
Protecting Microsoft 365 from on-Premises Attacks
Cloud Security

How to Protect Microsoft 365 from On-Premises Attacks?

Microsoft 365 is diverse enough to enrich the capabilities of many types of private businesses. It complements users, applications, networks, devices, and whatnot. However, Microsoft 365 cybersecurity is often compromised and there are countless ways that

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.