[Powershell]
There are 2x arrays $arrayRG:
testRG1
testRG2
testRG3
and appropriate $arrayVM:
testVM1
testVM2
testVM3
The problem:
How to run the code below to stop VMs, so values would be taken from arrays, something like:
Stop-AzureRmVM -ResourceGroupName "testRG1" -Name "testVM1"
...
Trying foreach logic, but can not figure out how to grab both values, as below takes only ResourceGroup:
foreach ($VM in $arrayRG)
{
Stop-AzureRmVM -ResourceGroupName $VM -Name "how to get name here?"
}
------------Other option tried-----------
Using hash tables, but still no luck. Managed to get $hash like this:
Name Value
testRG1 TestVM1
testRG2 TestVM2
testRG3 TestVM3
when tried foreach on a hash table unsuccessfully:
foreach ($VM in $hash)
{
Stop-AzureRmVM -ResourceGroupName $VM.Keys -Name $VM.Values
}