Download presentation
Presentation is loading. Please wait.
Published byRichard Flowers Modified over 6 years ago
1
Azure and Powershell - May the Force Be With You!
Tommy Skaue, Axdata
2
Agenda Getting started with PowerShell
Prerequisites, Considerations, Tips Usage in relation to Dynamics AX Community Scripts, PowerShell Remoting What about PowerShell and Azure Connecting to Azure, Using RunBooks (Azure Automation) What is required to use PowerShell Some considerations and tips when working with Powershell How PowerShell comes into play with Dynamics AX Some examples of shared scripts Example of the power of PowerShell using it for remoting Powershell in relation to Azure Running scripts locally to connect to Azure Using Azure as vehicle for running scripts using Azure Automation with runbooks, variables and schedules 2
3
PowerShell 101 Preinstalled from Windows 2008 R2 / Windows 7 Integrated Scripting Environment (ISE) PowerShell profiles Beginners tips Get Help and Documentation Some history V1 came November will be 10 years old in 2016 PS2 came with Win2k8 / Win7 PS3 came with Win2k12 / Win8 PS4 came with Win2k12 R2 / Win8.1 You can install PS4 Win7 SP1 / Win2k8 R2 SP1 PS5 released Februar 2016 ISE (Integrated Scripting Environment) Introduced with PS2 (Win2k8 /Win7) Recommended One tool for both scripting and command line Copy + Paste Intellisense, Syntax Highlighting, Window size, Tabs, Zoom, Addons Powershell profiles User or Global (all users), command line or Shell. Customize your profile if you want some modules to be loaded automatically. Tips (best shown in demo) Execution Policy defaults to Restricted, scripts will not run. (Set-ExecutionPolicy RemoteSigned) will allow local scripts and only remote signed/trusted scripts Reason for restrictions is PowerShell is: Native to Windows Able to call the Windows API Able to run commands without writing to the disk Able to avoid detection by Anti-virus Already flagged as "trusted" by most application white list solutions A medium used to write many open source Pentest toolkits Consider LineBreak executes commands Escape symbol is the backquote, backtick or grave accent symbol (`n instead of \n) Piping (axmodel | select name, layer | format-table –autosize) Discard output 1 send to null any > $null 2 declare to null variable $null = any 3 pipe with Out-Null any | Out-Null 4 prefix with [void] any Splatting, using a hash table to collect parameters and pass one chunk of varibles. example get-axmodel –server server –database database –model ‘usr model’ with splatting $parms model»} Create your own script and get Help Include script Help get-service help get-service -parameter computername Get-alias -definition get-service Get-alias gsv
4
DEMO Demo Tips and Profiles Show CLI and ISE
Show some basic commands with piping (get-service | where {$_status –eq ‘running’} | out-gridview) Show ISE advantages Resizing Intellisens Copy + Paste With or without script pane (CTRL + R) Tabs LIVE DEMO!
5
Community Scripts Dynamics AX dynamicsaxbuild.codeplex.com Day2DayDynamics day2daydynamics.codeplex.com Dynamics AX MVP Martin Draab and former AX MVP Joris de Grutyer PowerShell scripts Has scripts for starting and stopping AOS, get configuration from AXC files, Starting AX client with different settings Building and compiling Syncronizing database Day2DayDynamics by John Hagler Has similar scripts which some depends on DynamicsAxCommunity (0.3.5) scripts. Example of profile
6
DEMO Download DynamicsAXCommunity
Download D2D Demo Start AOS from DynamicsAxCommunity Demo Start Client from DynamicsAxCommunity Demo DB Sync form D2D Demo DB Restore from D2D
7
PowerShell Remoting Running scripts on a remote machine Depends on WSMAN, WinRM Service Uses Industry Standard Protocols Secure and encrypted Powershell remoting Supported from Vista SP1, Win7, Win2k8 + R2 Win7 later has WinRM 2.0 Get-Service winrm Enable-PSRemoting -force winrm s winrm/config/client Depends on WSMAN Can be used instead of Legacy DCOM and RPC Uses WinRM Service Industry standard Protocol Connects 5985 and 5986 (SSL) communcation is encrypted. Uses Kerberos and works well within a Windows Server Domain Requires local admin on remote machine out of the box Uses PSSession and creates a runspace on the remote machine Tips
8
PowerShell Remoting on Azure
PowerShell remoting to run scripts on Azure VM Uses SSL when remoting Download and Install Azure PowerShell Modules Azure commandlets Install-Module Azure -Force
9
DEMO Demo on Powershell Remoting Demo on remoting on a VM in Azure
10
Azure Automation Create User in Azure for Automation
Users Role can be «User» Grant user co-admim on Azure Subscription Log in once in order to activate the user with a non-temporary password and check the co-admin permission In order to operate on resources deployed through LCS you need to create a Automation User User must be added as co-admin to the subscription
11
Azure Automation Setup Azure Automation
Create Automation Account (any region) using the Classic Portal Create a Credential entry in the Azure Account Assets using a user that has co-admin permissions You can create the automation Account in both the new and the classic portal The region only matters of you plan to differentiate apply policies to isolate data. According to Microsoft scripts run using an account closer to the region where it is located may run faster. Create a new Credential Asset to hold the credentials (username and password) for the account.
12
Azure Automation Create RunBook
Create variables as Assets for the RunBook Create new PowerShell WorkFlow You can create variables to hold potential input to runbooks.
13
Azure Automation Edit and Test RunBook Edit RunBook
Test the runbook using the variables When creating RunBooks you can always test them before publishing. The published RunBook will be available for schedule. There is no revisioning besides the lates edit and the latest pushished version.
14
Azure Automation Schedule and Audit
Create a new Scheduled Job using the Runbook with the Variables as input Auditing When creating a schedule you assign the variables to the runbook in addition to the time and frequency of the schedule. TIP!! Change the Price Tier to prevent scripts from being stopped.
15
DEMO Demo of creating a runbook.
16
Final reminders CPE Credit Code: 53C2 Complete Surveys 16
17
Headshot And/Or Company Logo
Speaker contact info Tommy Skaue Axdata ( Headshot And/Or Company Logo 17
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.