# PowerShell Efficiency

**URL:** <https://forums.powershell.org/t/powershell-efficiency/16008>\
**Category:** PowerShell Help\
**Created:** [March 18, 2021, 2:48pm UTC](https://forums.powershell.org/t/powershell-efficiency/16008 "2021-03-18T14:48:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbell](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@jbell](https://forums.powershell.org/u/jbell)\
**Post date:** [March 18, 2021, 2:48pm UTC](https://forums.powershell.org/t/powershell-efficiency/16008/1 "2021-03-18T14:48:23Z")

</div>

Hello,

I am an Azure engineer and administrator that is trying to get on top of Azure PowerShell so that I can deploy and manage Azure resources using Infrastructure as Code. I know the basics of PowerShell, however, I would very much like to become an expert at the subject.

An example of this is deploying Azure resource groups, something fairly simple to do when trying to deploy a single group, but when deploying multiple groups I am struggling to write the code more efficiently.

Example Code:

```auto
New-AzSubscriptionDeployment -Name $DeploymentName -Location UKSouth -TemplateFile Location -TemplateParameterFile Location

```

If I wanted to create multiple resource groups I would just run this command twice but change the details in the ARM template, however, I wanted to know how to create multiple resource groups using a single PowerShell command if possible?

If someone could point me in the right direction I would be grateful.

Thank you.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [March 18, 2021, 3:02pm UTC](https://forums.powershell.org/t/powershell-efficiency/16008/2 "2021-03-18T15:02:38Z")

</div>

Welcome to the forums.

Powershell is easily able to handle lists/arrays of elements with loops like [about\_foreach](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7.1) or [Foreach-Object](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.1). That’s actually a very basic technique. If you’re not familiar with this you may restart learning the very basics of PowerShell first. That will save you from a lot of wasted time and frustration.

A - as I think - still good starting point would be this: [Getting Started with PowerShell 3.0](https://channel9.msdn.com/Series/GetStartedPowerShell3) (don’t worry if it’s not about the current version of PowerShell - the basics are still the same 😉 )

Regardless of that: When you post code please format it as code. Thanks in advance.  
Here you can read how that works:

> [@Guide to Posting Code - Redux](https://forums.powershell.org/t/guide-to-posting-code-redux/15797):
>
> Discourse uses [Markdown](https://www.markdownguide.org/getting-started/) for text formatting. There is a reference sheet and quick tutorial here: [Markdown Reference](https://commonmark.org/help/) You can produce in-line code formatting by wrapping your code in backticks (`). For example, `Get-ChildItem` produces Get-ChildItem. For larger code blocks, place a line containing three backticks above and below your code. For example ``` # 256-Color Foreground & Background Charts echo “`n$esc[1;4m256-Color Foreground & Background Charts$esc[0m” foreach ($fgbg in 38,48) { #…

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/powershell-efficiency/16008/3 "2024-05-16T20:27:01Z")

</div>


