4. 4CONFIDENTIAL
PowerShell
Command line and scripting language
- As interactive and composable as BASH/KSH
- As programmatic as Perl/Python/Ruby
- As production oriented as AS400 CL/VMS DCL
7. 7CONFIDENTIAL
The Pipeline
o PowerShell has an extremely powerful pipeline that
works unlike anything that’s really been done before
o It carries the output of one command to the input of
the next… but it does so in an amazingly flexible way
o If you can master the pipeline (and the help system
helps!)
9. 9CONFIDENTIAL
Objects
• You may have heard that PowerShell is an object-oriented
shell
• People make a big deal of this because it enables a lot…
but conceptually it’s pretty simple
• Ever see an Excel spreadsheet? It’s just a data structure,
right? Well, that’s all objects are. Data structures, in
memory.
• Every PowerShell command (well, most) produces objects…
and PowerShell will even show you everything about them
10. 10CONFIDENTIAL
Directly Using .NET Resources
Pre-loaded assemblies
[AppDomain]::CurrentDomain.GetAssemblies()
[AppDomain]::CurrentDomain.GetAssemblies() | `
ForEach-Object `
{ if ($_.GlobalAssemblyCache){ $_.Location.ToString().Split("")[4]}}
System
System.Drawing
System.Xml
System.Configuration
System.Management.Automation
Microsoft.PowerShell.Commands.Utility
Microsoft.PowerShell.ConsoleHost
Microsoft.PowerShell.Commands.Management
Microsoft.PowerShell.Security
System.Web.Services
16. 16CONFIDENTIAL
More specific queries
PS C:> ((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes |
Where-Object ResourceTypeName -eq sites).Locations
Brazil South
East Asia
East US
Japan East
Japan West
North Central US
North Europe
South Central US
West Europe
West US
Southeast Asia
Central US
East US 2
20. 20CONFIDENTIAL
Dynamic template parameters
PS C:> New-AzureRmResourceGroupDeployment -ResourceGroupName TestRG1 -TemplateFile
c:AzureTemplatesazuredeploy.json -hostingPlanName freeplanwest -serverName
exampleserver -databaseName exampledata -administratorLogin exampleadmin
cmdlet New-AzureRmResourceGroupDeployment at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
administratorLoginPassword: ********
21. 21CONFIDENTIAL
Get information about your resource groups
PS C:>Get-AzureRmResourceGroup
Get all of the resource groups:
To get the resources in the resource group, use the Find-AzureRmResource cmdlet and its
ResourceGroupNameContains parameter
PS C:> Find-AzureRmResource -ResourceGroupNameContains TestRG1
22. 22CONFIDENTIAL
Modify Resource Group
PS C:> $resource = Get-AzureRmResource -ResourceName ExampleApp -ResourceGroupName
OldRG
PS C:> Move-AzureRmResource -DestinationResourceGroupName NewRG -ResourceId
$resource.ResourceId
Move resources from one group to another:
Delete resource from Resource Group:
PS C:> Remove-AzureRmResource -Name TestSite -ResourceGroupName TestRG1 -
ResourceType "Microsoft.Web/sites" -ApiVersion 2015-08-01
Delete Resource Group:
PS C:> Remove-AzureRmResourceGroup -Name TestRG1
26. 26CONFIDENTIAL
What is Azure Automation?
Microsoft Azure Automation provides a way for
users to automate the manual, long-running,
error-prone, and frequently repeated tasks that
are commonly performed in a cloud and
enterprise environment. It saves time and
increases the reliability of regular
administrative tasks and even schedules them
to be automatically performed at regular
intervals
27. Azure
Monitoring
Systems
Change
Control
Systems
Anything
Runbook Authoring in Azure:
Create runbooks to automate all aspects of
cloud operations, from deployment,
monitoring, and optimizations
Highly Available Engine:
Support requirements for scale and H/A.
Built on PowerShell Workflow. Isolation for
runbook jobs
Integration into other systems:
Import PS modules and create additional
modules and runbooks for Azure services or
to connect into 3rd party systems
Automation
29. Patch Azure IaaS VMs without
downtime, leveraging Traffic
manager.
Enable regeneration of storage
account keys while avoiding
downtime in the application.
SQL Backup on a schedule.
Backup and restore IaaS VMs.
Deploy a VM on an Azure / On-
Premise cloud and enable
monitoring for the VM.
Deploy a new service to Azure and
configure the end points for CPU
and Memory alerts.
Deploy application from Git, run
validation tests, and swap to
production if tests pass.
Monitor SharePoint online for an
approval to update a service and
update the service once approved.
Alert on a VM then turn on
tracing, collect logs, upload to
Azure Storage and make available
in Visual Studio for
troubleshooting.
Monitor for when a new service
gets created, and configure it for
the right tracing / backup policy.
Notify users of a subscription who
have underutilized VMs and
perform remediation.
Change Control &
Provisioning
35. 35CONFIDENTIAL
In Review
Azure Automation enables:
• Integration into Azure services and external systems
• Implement your tasks using PowerShell workflow
• Automate everything!!!!