Create list of distribution groups with incremental numbers

I'm looking to find a way to create distribution groups in Exchange Powershell and each group will end with a number up until 50.

The base group name will be "TestGroup" followed by 001, 002, 003 and so on until 050.
How could you do it in powershell to create the distribution group automatically with the numbering, without having to pre-type it out and import as a text/csv?    

New-DistributionGroup -Name "TestGroup001" -OrganizationalUnit "" -SamAccountName "TestGroup001" -Type "Distribution"

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can just use the While loop.. something like:
$i = 1
While ($i -le 50) {$g = "TestGroup{0:000}" -f $i; New-DistributionGroup -Name $g -OrganizationalUnit "" -SamAccountName $g -Type "Distribution"; $i +=1}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Will SzymkowskiSenior Solution ArchitectCommented:
What you could do for this is have a CSV file with all of your names and use the following script...

CSV should have the Column Name

$Import = import-csv "c:\filename.csv"
ForEach ($DG in $Import) 


            New-DistributionGroup  -Name $DG.Name -SamAccountName $DG.Name 


Open in new window

garryshapeAuthor Commented:
MLanda thanks what is the {0:000} is that an operator? ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.