{"id":80436,"date":"2016-11-08T10:29:45","date_gmt":"2016-11-08T18:29:45","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=80436"},"modified":"2019-02-18T09:10:22","modified_gmt":"2019-02-18T16:10:22","slug":"part-3-how-to-avoid-reinventing-the-wheel-in-azure-automation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/part-3-how-to-avoid-reinventing-the-wheel-in-azure-automation\/","title":{"rendered":"How to avoid reinventing the wheel in Azure Automation"},"content":{"rendered":"<p><strong>Summary:<\/strong> Take advantage of existing scripts to create your own solutions.<\/p>\n<p>&nbsp;<\/p>\n<p>Automation is the number one technical skill that IT needs to have to thrive in today\u2019s quickly changing world. My recommendation is that anything you do for automation you should do in PowerShell, and you should use Azure Automation as your go-to automation solution.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/one.png\" alt=\"Powershell Wizard\" width=\"285\" height=\"276\" class=\"alignnone size-full wp-image-6705\" \/>\n<span style=\"font-size: 8.0pt;font-family: 'Segoe UI',sans-serif;color: black\">(<i>PoSH Wizard illustration courtesy of <\/i><\/span><span style=\"font-size: 8.0pt;font-family: 'Segoe UI',sans-serif\"><a href=\"http:\/\/myitforum.com\/myitforumwp\/\"><i>myITforum.com<\/i><\/a><span style=\"color: black\">)<\/span><\/span><\/p>\n<p>The Microsoft Operations Management Suite provides functionality around log analysis, backup and recovery, security and compliance, and IT automation. IT automation uses Azure Automation and is described as a method to \u201cautomate manual and repeated tasks using runbooks and graphical workflow-authoring tools\u201d. As you drill into the IT automation parts of OMS, what you find is that this <a target=\"_blank\" href=\"https:\/\/www.microsoft.com\/en-us\/cloud-platform\/automation-and-control\">IT automation solution<\/a> is <a target=\"_blank\" href=\"https:\/\/azure.microsoft.com\/en-us\/services\/automation\/\">Azure Automation<\/a>. Azure Automation enables you to utilize PowerShell or PowerShell workflows (or graphically based workflows) to provide automation both in the cloud and in your on-premises environment (using the <a target=\"_blank\" href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/automation-hybrid-runbook-worker\/\">Azure Hybrid Runbook Worker<\/a>).<\/p>\n<p>When you are coding in PowerShell, it is best to work from what already exists rather than creating it from scratch. This not only shortens the time to create new scripts, it also increases the quality through working from other functional approaches. This leads to the logical question \u2013 \u201c<em>Where do you find reusable PowerShell scripts?<\/em>\u201d To answer this question, I reached out to the Catapult Systems <a target=\"_blank\" href=\"http:\/\/www.catapultsystems.com\/services\/digital\/productivity\/launch\/\">Launch<\/a> PowerShell team, and I asked them where they get their scripts when they are building new functions for <a href=\"http:\/\/www.prnewswire.com\/news-releases\/catapult-systems-introduces-launch-its-new-it-and-business-automation-solution-300237866.html\">Launch<\/a>. Here are the top 15 recommendations that I received from the team:<\/p>\n<ol>\n<li>Start with your search engine of choice (<a target=\"_blank\" href=\"http:\/\/www.bing.com\/\">Bing<\/a>, <a target=\"_blank\" href=\"http:\/\/www.google.com\/\">Google<\/a>). These are still the quickest way to get results most of the time.<\/li>\n<li>TechNet Blogs\/documentation (<a href=\"http:\/\/blogs.technet.com\/\">http:\/\/blogs.technet.com\/<\/a>)<\/li>\n<li>TechNet Forums (<a target=\"_blank\" href=\"https:\/\/social.technet.microsoft.com\/Forums\/en-US\/home\">https:\/\/social.technet.microsoft.com\/Forums\/en-US\/home<\/a>)<\/li>\n<li>TechNet Gallery (<a target=\"_blank\" href=\"https:\/\/gallery.technet.microsoft.com\/\">https:\/\/gallery.technet.microsoft.com\/<\/a>)<\/li>\n<li>TechNet ScriptCenter \u201cScripting Guys\u201d (<a target=\"_blank\" href=\"https:\/\/technet.microsoft.com\/en-us\/scriptcenter\/dd901334.aspx\">https:\/\/technet.microsoft.com\/en-us\/scriptcenter\/dd901334.aspx<\/a>)<\/li>\n<li>Stack Overflow (<a target=\"_blank\" href=\"http:\/\/stackoverflow.com\/\">http:\/\/stackoverflow.com\/<\/a>)<\/li>\n<li>Reddit (<a target=\"_blank\" href=\"https:\/\/www.reddit.com\/r\/powershell\">https:\/\/www.reddit.com\/r\/powershell<\/a>)<\/li>\n<li>org (<a target=\"_blank\" href=\"http:\/\/powershell.org\/wp\/\">http:\/\/powershell.org\/wp\/<\/a>)<\/li>\n<li>CodePlex (<a target=\"_blank\" href=\"http:\/\/www.codeplex.com\/\">http:\/\/www.codeplex.com\/<\/a>)<\/li>\n<li>GitHub (<a target=\"_blank\" href=\"https:\/\/github.com\/\">https:\/\/github.com\/<\/a>)<\/li>\n<li>SS64 (<a target=\"_blank\" href=\"http:\/\/ss64.com\/\">http:\/\/ss64.com\/<\/a>)<\/li>\n<li>MSDN documentation (<a target=\"_blank\" href=\"https:\/\/code.msdn.microsoft.com\/site\/search?query=powershell&amp;f%5B0%5D.Value=powershell&amp;f%5B0%5D.Type=SearchText&amp;ac=4\">https:\/\/code.msdn.microsoft.com\/site\/search?query=powershell&amp;f%5B0%5D.Value=powershell&amp;f%5B0%5D.Type=SearchText&amp;ac=4<\/a>)<\/li>\n<li>Azure documentation (<a target=\"_blank\" href=\"\/\/www.azure.com\/\">http:\/\/www.azure.com<\/a>)<\/li>\n<li><span> <\/span><a href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/introducing-the-azure-automation-runbook-gallery\/\">Azure Automation Runbook Gallery<\/a><\/li>\n<li><a target=\"_blank\" href=\"http:\/\/blogs.catapultsystems.com\/cfuller\/archive\/2014\/06\/10\/creating-a-first-simple-runbook-in-sma-to-connect-to-operations-manager\/\">Service Management Automation sample runbooks<\/a><\/li>\n<\/ol>\n<p>So, how can you take these scripts and examples that you find online and use them in your environment? Well, there are a couple of tips that I can give to help you. The first is, you don\u2019t necessarily need to find a script that does exactly what you are looking to automate. Usually, you find a script that does about 80% of what you want. Then, all you have to do is finish the other 20%. Second, learn what the script is doing and how it is doing it. Doing this will help you manipulate the scripts and examples to get the results you want. Open the script in the PowerShell integrated scripting environment (ISE) and go through it line by line. Then, if you ever have any problems, you\u2019ll have a good idea of where to start troubleshooting. And finally, don\u2019t be afraid to ask questions. Most of the sites mentioned previously are community sites that have user boards and comment sections. Feel free to ask any questions. Most people on those sites are there to help, and enjoy it. Now, let\u2019s look at a few examples to give you some ideas of how you can apply these practices.<\/p>\n<h2>Using gallery scripts<\/h2>\n<p>Let\u2019s say, for example, that we want to connect to an Azure virtual machine and return any Windows Services that are set to start automatically but are not currently running. We could connect via remote desktop (RDP), open the PowerShell window, and run the following command.<\/p>\n<p style=\"padding-left: 60px\"><code>Get-WMIObject win32_service -Filter \"startmode = 'auto' AND state != 'running'\"<\/code><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA05.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA05.png\" alt=\"Windows Services that are set to start automatically but are not currently running\" width=\"615\" height=\"451\" class=\"alignnone size-full wp-image-80445\" \/><\/a><\/p>\n<p>But, let\u2019s say that we need to run this on multiple virtual machines a couple times a day. In this case, we will want to automate it. To do this, we will need to determine the required steps. In this instance, we will first need to connect to the virtual machine and then run the script. Because we already have the command that we need to run, all we need to do is figure out how to connect to an Azure virtual machine.<\/p>\n<p>If you connect to your Azure Automation instance, you can browse the gallery for existing scripts.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA01.png\" alt=\"Browse gallery button\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80455\" \/><\/a><\/p>\n<p>If you look through the gallery, you\u2019ll find a script named <em>Connect to an Azure Virtual Machine<\/em>, which looks like it fulfills the step we need of connecting to an Azure virtual machine.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA02-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA02-HSG-110816.png\" alt=\"The &quot;Connect to an Azure Virtual Machine&quot; script in the gallery\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80465\" \/><\/a><\/p>\n<p>You can import this script directly from the Azure Automation gallery to your Azure Automation instance.\n<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA04-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA04-HSG-110816.png\" alt=\"Script imported from the Azure Automation gallery to an Azure Automation instance\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80475\" \/><\/a><\/p>\n<p>After you have it imported, you\u2019ll want to open it in Edit mode and look at the script. The first thing you\u2019ll want to do is look through the help information at the top. Luckily this script, unlike many you will find out there, contains a lot of help information in the header. Second, you want to take a look at the parameters. Looking at the parameters of this script, you\u2019ll see that it is asking for three strings, the Azure subscription name, service name, and virtual machine name. There is also a fourth parameter named <strong>$AzureOrgIdCredential<\/strong>, and it is <strong>PSCredential<\/strong> type.<\/p>\n<p style=\"padding-left: 60px\"><code>Param\n(<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$AzureSubscriptionName,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[PSCredential]\n$AzureOrgIdCredential,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$ServiceName,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$VMName<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>)<\/code><\/p>\n<p>Because you can\u2019t pass a <strong>PSCredential<\/strong> object by using the Test Pane or the Start Runbook link, you must figure out how you can execute this runbook. There are two options I can see here. One, you can invoke this runbook from another runbook by passing a credential object. Or, you can change this credential parameter to a string, and add a command to the runbook\u2019s script to return a credential asset from Azure Automation. Either way is a viable option, but you will need to think about the pros and cons of each. If you invoke the runbook from another runbook, you could cause a headache if you needed to troubleshoot the runbook because you will not be able to run it from the Test Pane directly. However, if you change it to a string and add the command to use an Azure Automation credential, you\u2019ve now made this script unique to Azure Automation. Because Azure Automation is going to be the only place we will use this script, let\u2019s go with option two.<\/p>\n<p>Now as you can see in the following example, I\u2019ve updated the parameter to be a string and changed its name. Then, I added a line to the parameters to return the Azure Automation asset based on the string provided.<\/p>\n<p style=\"padding-left: 60px\"><code>Param\n(<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$AzureSubscriptionName,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[string]\n$AzureOrgIdCredentialAsset,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$ServiceName,<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>[parameter(Mandatory=$true)]\n[String]\n$VMName<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>)<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>$AzureOrgIdCredential = Get-AutomationPSCredential -Name $AzureOrgIdCredentialAsset<\/code><\/p>\n<p>Now you can run this script by using the Test Pane. After\u00a0the script finishes, you will see that it returns the <strong>WinRM Uri<\/strong> that you then can use to connect to your virtual machine.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA06-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA06-HSG-110816.png\" alt=\"Results from the script\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80485\" \/><\/a><\/p>\n<p>This now leaves us with another choice. We can save this Uri to a variable in this script and then use the <strong>Invoke-Command<\/strong>\u00a0cmdlet to run our command that checks the services. Or, we can call this runbook from another runbook, save the output as a variable, and then use the <strong>Invoke-Command<\/strong>\u00a0cmdlet in this second runbook. This time the decision is a lot easier to make. If we go with option one, then this entire runbook with all the connection commands will be tied to this very specific task of querying the services. However, option two will let\u00a0us to reuse this runbook for other automations that we may have in the future. Take, for example, if something changes in the way you need to return an Uri, you will only have to update one runbook, not every single runbook that you may have copy and pasted these commands into. You can see this all put together in the following example.<\/p>\n<p style=\"padding-left: 60px\"><code>workflow Check-AzureVMServices\n{<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>Param\n(<\/code><\/p>\n<p style=\"padding-left: 180px\"><code>[parameter(Mandatory=$true)]\n[String]\n$AzureSubscriptionName,<\/code><\/p>\n<p style=\"padding-left: 180px\"><code>[parameter(Mandatory=$true)]\n[string]\n$AzureOrgIdCredentialAsset,<\/code><\/p>\n<p style=\"padding-left: 180px\"><code>[parameter(Mandatory=$true)]\n[String]\n$ServiceName,<\/code><\/p>\n<p style=\"padding-left: 180px\"><code>[parameter(Mandatory=$true)]\n[String]\n$VMName,<\/code><\/p>\n<p style=\"padding-left: 180px\"><code>[parameter(Mandatory=$true)]\n[String]\n$VMCreds<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>)<\/code><\/p>\n<p style=\"padding-left: 120px\"><code># Get the WinRM Uri so that it can be used to connect to the VM\n$WinRmUri = Connect-AzureVM -AzureSubscriptionName $AzureSubscriptionName -ServiceName\n$ServiceName -VMName $VMName -AzureOrgIdCredential $AzureOrgIdCredentialAsset<\/code><\/p>\n<p style=\"padding-left: 120px\"><code># Get the credential asset with permissions to connect to the VM\n$Creds = Get-AutomationPSCredential -Name $VMCreds<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>InlineScript {\n# Execute the script block on the remote VM\nInvoke-Command -ConnectionUri $Using:WinRmUri `<\/code><\/p>\n<p style=\"padding-left: 150px\"><code>-Credential $Using:Creds `\n-ScriptBlock {Get-WMIObject win32_service -Filter \"startmode = 'auto' AND state != 'running'\"}<\/code><\/p>\n<p style=\"padding-left: 120px\"><code>}<\/code><\/p>\n<p style=\"padding-left: 60px\"><code>}<\/code><\/p>\n<p>You might\u00a0have noticed in this example that I used a PowerShell Workflow runbook. There are a couple of reasons for this. The first one is that\u00a0you can only call an Azure Automation PowerShell Workflow runbook from another PowerShell Workflow runbook. The second is that PowerShell Workflow works great for platforms like Azure Automation because it can\u00a0create Checkpoints, Pause, and Resume. For more information about\u00a0this, refer to Ed\u2019s previous post <a target=\"_blank\" href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/01\/16\/powershell-workflows-job-engine\/\">PowerShell Workflows: Job Engine<\/a>.<\/p>\n<h2>Using existing scripts<\/h2>\n<p>The previous example is a great use case for using Azure Automation to connect to cloud-based resources, but what if you need to run scripts in your on-premises environments. Well, Azure Automation provides a great mechanism for that, the Hybrid Worker. When the Hybrid Worker is connected to your OMS subscription, you can execute Azure Automation runbooks locally. This provides multiple advantages such as source control, scheduling, secure credential storage, logging, and auditing. For example, you could set up a script to run via a scheduled task. But, you would need to keep a copy of that script somewhere so the server can access it and hope that nobody edits or deletes it. Plus, you will need to store your credentials in the task, or, even worse, directly in the script. Now, imagine that you need to do this for 100 or even 10 machines. It would be a logistical nightmare. With Azure Automation and the Hybrid Worker, you can achieve this very easily.<\/p>\n<p>In this example we\u2019re going to use one of the most downloaded scripts from the TechNet gallery, <a target=\"_blank\" href=\"https:\/\/gallery.technet.microsoft.com\/Delete-files-older-than-x-13b29c09\">Delete files older than x-days &#8211; Cleanup Script<\/a>. However, keep in mind, these steps can apply to pretty much any script that you currently have or plan to write. This script does exactly what the name implies, It can be used to delete files over a set number of days old. Even though this script was not designed for Azure Automation, we can download it from TechNet, import it to Azure Automation, and it is pretty much ready to run on my Hybrid Worker.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA07-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA07-HSG-110816.png\" alt=\"Importing an existing runbook\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80495\" \/><\/a><\/p>\n<p>I said pretty much ready to run because there are a couple of things you need to do before you can execute the script on your Hybrid Worker. This first, and this goes for every script that you import, you need to publish it. All scripts import in a New state and cannot be run until they are published.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA08-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA08-HSG-110816.png\" alt=\"The Publish button\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80505\" \/><\/a><\/p>\n<p>The second thing we\u2019ll need to do for this particular script is to change the parameters that are a <strong>Switch<\/strong> type to a <strong>Boolean<\/strong> type. It is considered best practices to use <strong>Boolean<\/strong> in Azure Automation runbooks, and, in most cases, the <strong>Switch<\/strong> and <strong>Boolean<\/strong> parameters function the same inside the script. More details about why this is the case can be found <a target=\"_blank\" href=\"http:\/\/www.powershellmagazine.com\/2013\/12\/20\/using-powershell-switch-vs-boolean-parameters-in-sma-runbooks\/\">in this post<\/a>, but we will see one of the main reasons here shortly when we schedule this runbook to execute.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA09-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA09-HSG-110816.png\" alt=\"The updated parameters\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80515\" \/><\/a><\/p>\n<p>Now that you have your parameter types updated and your runbook published, you are all set to schedule it to run on your Hybrid Worker. Just go to the runbook in Azure Automation and click <strong>Schedule<\/strong>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA10-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA10-HSG-110816.png\" alt=\"The Schedule button\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80525\" \/><\/a><\/p>\n<p>In the <strong>Schedule<\/strong> blade, click <strong>Link a schedule to your runbook<\/strong>, and set the schedule you would like for this script to run. In this example I am setting it to run every Sunday at 1 AM.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA11-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA11-HSG-110816.png\" alt=\"Setting the schedule values for the runbook\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80535\" \/><\/a><\/p>\n<p>After you create the schedule, you can click <strong>Configure parameters and run settings<\/strong>. Here you can set the parameters that you want for this job.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA12-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA12-HSG-110816.png\" alt=\"Setting parameters for the job\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80545\" \/><\/a><\/p>\n<p>There are a few things you\u2019ll notice in the parameters. First, all the <strong>Boolean<\/strong> values have a drop-down to select <strong>True<\/strong> or <strong>False<\/strong>. Switch parameters do not do this so that is why it is advantageous to use <strong>Boolean<\/strong> values here. Also, at the very bottom, you\u2019ll see an option for <strong>Run Settings<\/strong>. By switching this to <strong>Hybrid Worker<\/strong>, you can select the Hybrid Worker that you want this script to execute on.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA13-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA13-HSG-110816.png\" alt=\"Selecting Hybrid Worker for run settings\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80546\" \/><\/a><\/p>\n<p>Once you set the parameters and click <strong>OK<\/strong>, the schedule is set. You can create multiple different schedules here, each with their own set of parameters and Hybrid Worker. You can view your existing schedules either at the runbook level or for all runbooks under <strong>Assets<\/strong> at the Automation Account level.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA14-HSG-110816.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/AA14-HSG-110816.png\" alt=\"View scheduled runbooks\" width=\"616\" height=\"330\" class=\"alignnone size-full wp-image-80555\" \/><\/a><\/p>\n<p>One final note, keep in mind that when these runbooks execute on your Hybrid Worker, they function like any other script. This means that for our previous example, you don\u2019t necessarily need to create a Hybrid Worker for every server I want to run this script on. You can set the path to a network share, or you can do like we did in the first example and use <strong>Invoke-Command<\/strong> to execute on a remote system. I\u2019ve said it before and I\u2019ll continue to say, if you can dream, and you can script it, Azure Automation can do it.<\/p>\n<p><strong>Summary<\/strong>: Azure Automation is an extremely powerful component of the Microsoft Operations Management Suite. If you haven\u2019t had the time to kick the tires on it yet, this is worth checking out. When you are looking for scripts to work from, utilize the list in this post to help you to get a jump-start on what you need to create.<\/p>\n<div class=\"site container-fluid\" id=\"page\">\n<div class=\"site-content row\" id=\"site-content\">\n<div class=\"content-area col-sm-9\" id=\"primary\">\n<div class=\"div-content\" id=\"single-content\">\n<article class=\"post-80255 post type-post status-publish format-standard hentry category-hey-scripting-guy category-windows-powershell tag-bash tag-guest-blogger tag-scripting-guy tag-stefan-roth tag-windows-powershell\" id=\"post-80255\">\n<div class=\"entry-content single\">\n<p>I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. Also, check out my <a target=\"_blank\" href=\"https:\/\/blogs.technet.microsoft.com\/msoms\/\">Microsoft Operations Management Suite Blog<\/a>. Until then, peace.<\/p>\n<p><strong>Ed Wilson\n<\/strong>Microsoft Scripting Guy<\/p>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Take advantage of existing scripts to create your own solutions. &nbsp; Automation is the number one technical skill that IT needs to have to thrive in today\u2019s quickly changing world. My recommendation is that anything you do for automation you should do in PowerShell, and you should use Azure Automation as your go-to automation [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568],"tags":[56,699],"class_list":["post-80436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","tag-guest-blogger","tag-stefan-roth"],"acf":[],"blog_post_summary":"<p>Summary: Take advantage of existing scripts to create your own solutions. &nbsp; Automation is the number one technical skill that IT needs to have to thrive in today\u2019s quickly changing world. My recommendation is that anything you do for automation you should do in PowerShell, and you should use Azure Automation as your go-to automation [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=80436"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80436\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=80436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=80436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=80436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}