-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-Getting Started.ps1
67 lines (54 loc) · 2.44 KB
/
01-Getting Started.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
<#########################################################
Author: Trevor Sullivan <[email protected]>
Description: This PowerShell script demonstrates how to get started with
Azure Automation using the Microsoft Azure PowerShell module.
COPYRIGHT NOTICE
This file is part of the "Microsoft Azure Automation" course, and is
copyrighted by Art of Shell LLC. This file may not be copied or distributed, without
written permission from an authorized member of Art of Shell LLC.
#########################################################>
### Install the Microsoft Azure Resource Manager (ARM) PowerShell module
Install-Module -Name AzureRM -Scope CurrentUser -Force;
### Install the Azure PowerShell Extensions (developed by Art of Shell)
Install-Module -Name AzureExt -Scope CurrentUser -Force;
### Install the Microsoft Azure Automation Authoring Toolkit (for PowerShell ISE)
Install-Module -Name AzureAutomationAuthoringToolkit -Scope CurrentUser -Force;
### Import the Azure Automation Authoring Toolkit
Import-Module -Name AzureAutomationAuthoringToolkit -Force;
### Inspect the commands for the Azure Automation module
Get-Command -Module AzureRM.Automation;
### Authenticate to Microsoft Azure using Azure Active Directory (AAD)
$AzureUsername = '[email protected]';
$AzureCredential = Get-Credential -Username $AzureUsername -Message 'Please enter your Microsoft Azure password.';
Add-AzureRmAccount -Credential $AzureCredential;
### Create a new Azure Resource Manager (ARM) Resource Group
$ResourceGroup = @{
Name = 'ArtofShell-Automation';
Location = 'West US';
Force = $true;
}
New-AzureRmResourceGroup @ResourceGroup;
### Create a new Azure Automation Account
$AutomationAccount = @{
ResourceGroupName = $ResourceGroup.Name;
Name = 'ArtofShell';
Location = 'West US';
Plan = 'Free'; ### Basic is also supported
Tags = @(
@{ Name = 'Company'; Value = 'Art of Shell'; };
@{ Name = 'Department'; Value = 'Marketing'; };
)
};
New-AzureRmAutomationAccount @AutomationAccount;
### Import an Azure Automation Runbook
Get-Command -Module AzureRM.Automation -Name *runbook*;
### Import an Azure Automation Runbook
$Runbook = @{
AutomationAccountName = $AutomationAccount.Name;
Path = '{0}\02-RunbookExample.ps1' -f $PSScriptRoot;
Description = 'This is an example Runbook';
Type = 'PowerShell';
Published = $true;
Force = $true;
};
Import-AzureRmAutomationRunbook @Runbook;