# Info Gathering

# List subscriptions for authenticated account

```powershell
az account list
```

# Get tenant id

```powershell
az account list | jq '.[].tenantId'
```

# Get subscription id

**az cli:**

```
az account list | jq '.[].id'
```

**Powershell:**

```
Get-AzSubscription
```

Resources:  
[Powershell docs](https://docs.microsoft.com/en-us/powershell/module/az.accounts/get-azsubscription?view=azps-5.5.0)  
[ClI docs](https://docs.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest)

# List tenants

```powershell
az account tenant list
```

# List Resource Groups by name

```
az group list | jq -r '.[].name'
```

Resource: [https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest](https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest)

# Set Subscription

**az cli:**

```
az account set -s <name or id>
```

**Powershell:**

```
Set-AzureSubscription -Id [Subscription ID]
```

Resources:  
[https://powerzure.readthedocs.io/en/latest/Requirements/requirements.html](https://powerzure.readthedocs.io/en/latest/Requirements/requirements.html)  
[https://stackoverflow.com/questions/38475104/azure-cli-how-to-change-subscription-default](https://stackoverflow.com/questions/38475104/azure-cli-how-to-change-subscription-default)

# List all VMs

```
az vm list
```

Resource: [https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest](https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest)