forked from robotechredmond/Azure-PowerShell-Snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzureStack - Getting Started with PowerShell.ps1
71 lines (51 loc) · 1.61 KB
/
AzureStack - Getting Started with PowerShell.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Get Azure AD Tenant ID
Login-AzureRmAccount
$aadTenantId =
(Get-AzureRmContext).Tenant.TenantId
# Register environment for Azure Stack
Add-AzureRmEnvironment `
-Name 'Azure Stack' `
-ActiveDirectoryEndpoint ("https://login.windows.net/$aadTenantId/") `
-ActiveDirectoryServiceEndpointResourceId "https://azurestack.local-api/" `
-ResourceManagerEndpoint ("https://api.azurestack.local/") `
-GalleryEndpoint ("https://gallery.azurestack.local:30016/") `
-GraphEndpoint "https://graph.windows.net/"
# Get Azure Stack environment
$azureEnv =
Get-AzureRmEnvironment `
-Name 'Azure Stack'
# Authenticate to Azure Stack environment
Login-AzureRmAccount `
-Environment $azureEnv
# Select Azure subscription
$subscriptionId =
(Get-AzureRmSubscription |
Out-GridView `
-Title "Select an Azure Subscription ..." `
-PassThru).SubscriptionId
Select-AzureRmSubscription `
-SubscriptionId $subscriptionId
# View ARM Resource Providers
Get-AzureRmResourceProvider |
Select-Object `
-Property ProviderNamespace `
-ExpandProperty ResourceTypes
# Select Azure Resource Group
$rgName =
(Get-AzureRmResourceGroup |
Out-GridView `
-Title "Select an Azure Resource Group ..." `
-PassThru).ResourceGroupName
# Select an Azure VM from Resource Group
$vmName =
(Get-AzureRmVm `
-ResourceGroupName $rgName).Name |
Out-GridView `
-Title "Select an Azure VM ..." `
-PassThru
$vm =
Get-AzureRmVm `
-ResourceGroupName $rgName `
-Name $vmName
# Get Azure VM Status
$vm | Get-AzureRmVm -Status