azure powershell can't find resource (vm) by name azure powershell can't find resource (vm) by name powershell powershell

azure powershell can't find resource (vm) by name


According to your description, it seems that your have multiple subscriptions and your VM is not in your default subscription. So, you need select correct subscriptions. Please refer the following steps:

1.Determine your subscription name and subscription id in Azure Portal.

enter image description here

2.Change the default subscription.

Get-AzureRmSubscriptionSelect-AzureRmSubscription -SubscriptionName "your subscription name"

Update:

If your VM is based on classic VM, you need use Get-AzureVM to list your VM.


Have you tried without specifying the resource group e.g.

#Login to your sublogin-azurermaccountSelect-AzureRmSubscription -SubscriptionName 'BizSpark'$vms = Get-AzureRmVM#list all the VMs returned by the above command$vms#first VM in the above collection$vms[0]#id of first vm$vms[0].id

If that doesn't work, it is worth checking you are running the latest version of the cmdlets as I have encountered some great behaviors that have been fixed by updating.https://docs.microsoft.com/en-us/powershell/azureps-cmdlets-docs/