Powershell to create multiple empty folders

I need to create about 40 folders numbers 11 through 50.

the folder's names will be 11, 12, 13, and so on.....
jamesmetcalf74Asked:
Who is Participating?

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

x
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.

oBdACommented:
In test mode; remove the -WhatIf argument to run it for real:
11..40 | % {New-Item -Path "C:\Temp\$($_)" -ItemType Directory -WhatIf}

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
Raymond PengSystems EngineerCommented:
This works perfectly. Hi obda, can you explain the logic with the $($_)?

What is the first $ representing? I know that the $_ is taking the items in the array and evaluating at the number value. Im new to ps and am still learning. Thanks!
oBdACommented:
"$()" is a sub-expression that, in this case, only contains a variable. In the command above, "C:\Temp\$_" would work as well, but I've gotten used to using subexpressions in strings whether they're needed or not.
So this would work: "Foo: $foo", as well as "Bar$foo". But this would fail (if we want the variable "$foo"): "Foo: $fooBar".
They're required as well, for example, when accessing properties of a variable, as in "File basename: $($FileItem.BaseName)", otherwise the parser would determine that the variable ended at the "." after "$FileItem".
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
Powershell

From novice to tech pro — start learning today.