Forgive me! I am just new to PShell and have been learning with use cases.
I'm trying to complete the following task in azure...
Find all VM's with the deallocated state, save the output to an azure automation variable, turn the VM's on....
I can complete most of these tasks individually but I'm struggling to put it all together.
#---Get all VMs in subscription
$VMs = Get-AzVM -status
#---Get deallocated VMs - This part needs to be replaced with set-azautomationvariable?
$DeallocatedVMs = $VMs | Where-Object { $_.PowerState -Like 'VM deallocated'}
#---Start Deallocated VMs
foreach ($VM in $DeallocatedVMs)
{
Start-AzVM -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName
}
I am interested to learn! Any assistance is appreciated!