-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzure CLI
101 lines (72 loc) · 3.08 KB
/
Azure CLI
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Azure Accounts
--------------------
Login to Azure Account:
Login-AzAccount
Logout of the Azure account you are connected with in yoursession:
Logout-AzAccount
Subscription Selection
--------------------
List all subscriptions in all tenants the account can access:
Get-AzSubscription
Get subscriptions in a specific tenant:
Get-AzSubscription -TenantId "xxxx-xxxx-xxxxxxxx"
Choose subscription:
Select-AzSubscription –SubscriptionID “SubscriptonID”
Resource Groups
--------------------
Get all resource groups (Gets the resource group and additional details which can also be stored for use by additional commands):
Get-AzResourceGroup
Get a specific resource group by name:
Get-AzResourceGroup -Name "myResourceGroup”
Delete a Resource Group:
Remove-AzResourceGroup -Name "ResourceGroupToDelete"
Virtual Machines
--------------------
List all VMs in current subscription:
Get-AzVM
List VMs in a resource group See Resource Groups section above):
Get -AzVM -ResourceGroupName $ResourceGroup
Get a specific virtual machine:
Get-AzVM -ResourceGroupName “resourcegroup” -Name "myVM"
Start a VM:
Start-AzVM -ResourceGroupName “resourcegroup” -Name “vmname”
Stop a VM:
Stop-AzVM -ResourceGroupName “resourcegroup” -Name “vmname”
Restart a running VM:
Restart-AzVM -ResourceGroupName “resourcegroup” -Name “vmname”
Delete a VM:
Remove-AzVM -ResourceGroupName “resourcegroup” -Name “vmname”
Networking
--------------------
List virtual networks:
Get-AzVirtualNetwork -ResourceGroupName “resourcegroup” #Lists all the virtual networks in the resource group.
Get information about a virtual network:
Get-AzVirtualNetwork -Name "myVNet" -ResourceGroupName “resourcegroup”
List subnets in a virtual network:
Get-AzVirtualNetwork -Name "myVNet" -ResourceGroupName “resourcegroup” | Select Subnets
Get information about a subnet:
Get-AzVirtualNetworkSubnetConfig -Name "mySubnet1" VirtualNetwork $vnet
#Gets information about the subnet in the specified virtual network. The $vnet value represents the object returned by Get-AzVirtualNetwork you used
previously.
Get all IP addresses from a resource group:
Get-AzPublicIpAddress -ResourceGroupName “resourcegroup”
Azure AD
--------------------
Connect to Azure Active Directory:
Connect-AzureAD #Note: You will be prompted to enter your credentials and any additional authentication steps required.
Disconnect from Azure Active Directory
Disconnect-AzureAD:
Get All users:
Get-AzureADUser
Get specific user:
Get-AzureADUser -ObjectId "[email protected]"
Remove User:
Remove-AzureADUser -ObjectId "[email protected]"
New User Creation:
This is a 3 step process that requires first creating a password profile, setting the password, and then passing these into the NewAzureADUser command
Create Password Profile:
$PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
Set Password:
$PasswordProfile.Password = "Password"
Create User:
New-AzureADUser -DisplayName "New User" -PasswordProfile $PasswordProfile -UserPrincipalName "[email protected]" -AccountEnabled $true -MailNickName "Newuser"