How to Get Only Azure Virtual Machines with PowerShell Without Affecting Other Services?

0
14
Asked By TechieTraveler92 On

I'm trying to gather Azure Virtual Machines using the PowerShell Az module, but I've noticed some odd behavior. When I use the `Get-AzVM` command, it returns `Microsoft.ComputevirtualMachines`, but that also includes VMs for Azure Virtual Desktop (AVD) and potentially other services. This becomes a problem when I try to stop VMs across a subscription or Resource Group; I end up impacting AVD hosts, causing outages for those services as well.

Why does this happen? It seems like one command can affect multiple services under the hood just because they share some resources. Is anyone else frustrated by this inconsistency? Why can't we run commands without risking other Azure services? For Virtual Machine Scale Sets (VMSS), the situation appears to be different, but I'd like to know more about this issue and its impact across Azure services.

4 Answers

Answered By DevOpsNinja3 On

You’ve got a point; AVD VMs are just like any other VMs since they connect to a host pool. Unlike other services that might be more abstracted, VMs are straightforward. If you want more control and less risk of affecting other services, consider using Windows 365 instead of AVD. You could also just scope the commands better; there isn’t often a need to stop every VM across a whole tenant.

Answered By VirtualMachineExpert On

This issue isn’t unique to Azure; you’d find similar behavior with services like VMWare or AWS. A VM is a VM, and that basic definition is the same across platforms. It’s all about how you manage and scope your commands.

Answered By CloudGuru77 On

It’s pretty much a skill issue here. AVD VMs are classified as VMs, so `Get-AzVM` won’t ignore them. However, you can refine your command by adding a filter. For example, use `Where-Object { $_.ResourceGroupName -ne '' }` to exclude AVD VMs from your results. Just be aware that if you're managing multiple subscriptions, it might not be easy to isolate all AVD resources.

ScriptSavvy10 -

That makes sense, but managing 60 subscriptions means you can’t guarantee that your script won’t disrupt AVD. It gets complicated when trying to identify which VMs are AVD without clear tags or identifiers, making it tough to make exceptions.

Answered By AzureWhizKid On

Filtering on specific parameters can definitely help. If your AVD VMs carry unique tags, you can use those to filter them out. It’s mostly about taking the initiative to customize your commands to avoid these issues. If things are failing, read up on how to structure your queries better!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.