{"id":15431,"date":"2018-07-19T06:00:40","date_gmt":"2018-07-19T13:00:40","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=15431"},"modified":"2018-07-31T10:30:13","modified_gmt":"2018-07-31T17:30:13","slug":"new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/","title":{"rendered":"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs"},"content":{"rendered":"<p>Our latest video shows two different ways\u00a0to execute a console AzureRM script as a job using PowerShell Studio 2018.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-15436\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-300x180.jpg\" alt=\"\" width=\"693\" height=\"416\" srcset=\"https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-300x180.jpg 300w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-768x462.jpg 768w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-1024x615.jpg 1024w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-848x510.jpg 848w, https:\/\/dev.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17.jpg 1208w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/a><\/p>\n<p>In this short video we demonstrate how to use the Azure cmdlet <em>Stop-AzureRmVM<\/em> to stop an Azure VM by submitting the script code as a background job in two different ways:<\/p>\n<p>1. Create the scriptblock containing the Azure cmdlet to be submitted as a job using the <em>Start-Job<\/em> cmdlet.<br \/>\n2. Create a more elaborate scriptblock containing the Azure cmdlet to be submitted as a job using the <em>-AsJob<\/em> parameter.<\/p>\n<p>Both jobs can save the status and any output results from the <em>Get-Job<\/em> and <em>Receive-Job<\/em> cmdlets.<\/p>\n<p>What&#8217;s involved in this process:<\/p>\n<ol>\n<li>Connect to Azure and execute the command.<\/li>\n<li>Use the\u00a0<em>Start-Job<\/em>\u00a0cmdlet to submit the scriptblock as a background job.<\/li>\n<li>Use the\u00a0<em>Do\/While<\/em> loop to display the job progress.<\/li>\n<li>Use the <em>Receive-Job<\/em> cmdlet to save the job results.<\/li>\n<li>Use the <em>Get-Job<\/em> cmdlet to display the saved job results at the end of the process.<\/li>\n<\/ol>\n<p>We also show the use of adding an argument by passing a parameter to the scriptblock.<\/p>\n<p>View the video here:\u00a0<a href=\"https:\/\/youtu.be\/_gTQLuCYdKw\" target=\"_blank\" rel=\"noopener\">SAPIEN PowerShell Studio: Working with Azure Cmdlets In Background Jobs<\/a><\/p>\n<h3>Take Way<\/h3>\n<p>This example provides a scripting framework that is not limited to Azure, and that can also easily be enhanced. It is better to use background jobs when working with Azure commands in a GUI application.<\/p>\n<p>Most importantly, store the code in a scriptblock and submit the job using the\u00a0<em>Start-Job<\/em> cmdlet. The <em>Receive-Job<\/em> cmdlet will save information generated by the job, and the\u00a0<em>Get-Job<\/em>\u00a0cmdlet will provide the status information of the background job\u2014so if the job doesn&#8217;t generate any output, then it will not save any data.<\/p>\n<h3>Sample Code<\/h3>\n<p>Feel free to copy\/paste the code against your AzureRM VM&#8217;s.<\/p>\n<h4>Check the AzureRM VM Status:<\/h4>\n<pre>## - Check for VM status:\r\nGet-AzureRmVM -ResourceGroupName 'GlobalAzureBootCampResources' -status `\r\n| Select-Object Name, PowerState;<\/pre>\n<h4>Run Stop-AzureRMVM without using the -AsJob parameter:<\/h4>\n<pre>#region RunStop-AzureRMVM_NoAsJobParam\r\n\r\n## 1 - Run Stop-AzureRMVM cmdlet without the -AsJob parameter:\r\n$JobName = \"StopVmScriptJob\";\r\n$JobScript = {\r\n\r\n## - Sign-On to Azure:\r\nImport-AzureRmContext -Path 'C:\\Temp\\WinPS_AsubRMprofile.json' | Out-Null;\r\n\r\n## - Run Azure cmdlet with AsJob parameter:\r\nStop-AzureRMVM -ResourceGroupName \"GlobalAzureBootCampResources\" `\r\n-Name 'Win2K16VM1' `\r\n-Force -Verbose;\r\n};\r\n\r\n## - Step that submit the scriptblock as a background job - ##\r\n$job = Start-Job -Name $Name -ScriptBlock $JobScript;\r\n\r\n## - Loop to check for The Stop-AzureRM cmdlet job completion:\r\n\"Processing Started - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\ndo {\r\nStart-Sleep -Seconds 10;\r\n\"Processing! - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n}\r\nwhile ((Get-Job).State -ne 'Completed');\r\n\"Process Completed - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n\r\n## - Saving Job results:\r\n$ReceiveJobStatus1 = Receive-Job -Job $job -Keep;\r\n$GetJobStatus1 = Get-Job;\r\n\r\n## - Displaying Job results:\r\n$ReceiveJobStatus1\r\n$GetJobStatus1 | Format-List;\r\n\r\n#endregion RunStop-AzureRMVM_NoAsJobParam<\/pre>\n<h4>Run Stop-AzureRMVM using the -AsJob parameter:<\/h4>\n<pre>#region RunStop-AzureRMVM_WithAsJobParam\r\n\r\n## 2 - Run Stop-AzureRMVM cmdlet with the -AsJob parameter:\r\n$JobName = \"StopVmCmdletAsJob\";\r\n$JobScript = {\r\nparam($Name)\r\n\r\n## - Sign-On to Azure:\r\nImport-AzureRmContext -Path 'C:\\Temp\\WinPS_AsubRMprofile.json' | Out-Null;\r\n$TaskName = \"StopVM1_$($Name)\";\r\n\r\n## - Run Azure cmdlet with AsJob parameter:\r\nStop-AzureRMVM -ResourceGroupName \"GlobalAzureBootCampResources\" `\r\n-Name $Name `\r\n-AsJob `\r\n-Force -Verbose;\r\n\r\n## - Inside Job Loop to check for the cmdlet job completion:\r\n\"`r`nProcess Started - $TaskName - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\ndo {\r\nStart-Sleep -Seconds 10;\r\n\"Processing! $TaskName - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n}\r\nwhile ((Get-Job).State -ne 'Completed');\r\n\"Process Ended - $TaskName - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n\r\n\"`r`nGetting Job General Results:\"\r\n$AzGetJobStatus1 = Get-Job\r\n$AzGetJobStatus1 | Format-List\r\n\r\n\"Getting Receive Results:\"\r\n$AzureReceiveJobStatus2 = Receive-Job * -Keep;\r\n$AzureReceiveJobStatus2 | Format-List\r\n}\r\n\r\n## - Step that submit the scriptblock as a background job - ##\r\n$job = Start-Job -Name $Name -ScriptBlock $JobScript -ArgumentList 'Win2K16VM1';\r\n\r\n## - Loop to check for The Stop-AzureRM cmdlet job completion:\r\n\"`r`nBackground Process Started - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\ndo {\r\nStart-Sleep -Seconds 10;\r\n\"Processing Job - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n}\r\nwhile ((Get-Job).State -ne 'Completed');\r\n\"Background Process Completed - $($JobName) - $((Get-Date).ToString(\"MM\/dd\/yyyy-MM:hh:ss\"))\"\r\n\r\n## - Saving Job results:\r\n$ReceiveJobStatus2 = Receive-Job -Job $job -Keep;\r\n$GetJobStatus2 = Get-Job\r\n\r\n## - Displaying Job results:\r\n$ReceiveJobStatus2\r\n$GetJobStatus2 | Format-List\r\n\r\n#endregion RunStop-AzureRMVM_WithAsJobParam<\/pre>\n<h3>Summary<\/h3>\n<p>Create and test the script using the PowerShell Console before implementing in a GUI application such as PowerShell Studio. This sample script will require some minor changes as you build the GUI application.\u00a0 Refer to the related articles below for more details.<\/p>\n<h3>Related Articles<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.sapien.com\/blog\/2018\/07\/12\/powershell-studio-how-to-prevent-powershell-cmdlets-from-hanging-in-gui-apps\/\">PowerShell Studio: How to prevent Powershell cmdlets from hanging in GUI apps<\/a><\/li>\n<li><a href=\"https:\/\/info.sapien.com\/index.php\/guis\/gui-advanced-tips\/powershell-studio-creating-responsive-forms\">PowerShell Studio: Creating Responsive Forms<\/a><\/li>\n<li><a href=\"https:\/\/www.sapien.com\/blog\/2018\/07\/31\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs-in-a-gui-app\/\">PowerShell Studio: Working with Azure cmdlets in Background Jobs in a GUI app<\/a><\/li>\n<\/ul>\n<h3>Instructional Videos<\/h3>\n<p>Learn about other SAPIEN Technologies product features by checking out the videos on our\u00a0<a href=\"http:\/\/youtube.com\/SAPIENTech\" target=\"_blank\" rel=\"noopener\">YouTube channel<\/a>.<\/p>\n<h3>Feedback<\/h3>\n<p>As always, if you have any ideas, comments, or feedback, please\u00a0<a href=\"https:\/\/www.sapien.com\/forums\/viewforum.php?f=23\" target=\"_blank\" rel=\"noopener\">visit our feedback forum<\/a>\u00a0and reference this post.<\/p>\n<p>&nbsp;<\/p>\n<p><em>Max Trinidad is a Technology Evangelist at SAPIEN Technologies Inc., and a Microsoft PowerShell MVP. You can reach him at\u00a0<a href=\"mailto:maxt@sapien.com\">maxt@sapien.com<\/a><\/em><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our latest video shows two different ways\u00a0to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1143,1238,703,410,1239,25],"tags":[28,1215,1016,37,997],"class_list":["post-15431","post","type-post","status-publish","format-standard","hentry","category-powershell","category-powershell-core","category-powershell-studio","category-primalscript-software-news","category-pscore6","category-windows-powershell","tag-powershell","tag-powershell-core","tag-powershell-studio","tag-primalscript","tag-windows-powershell"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Max Trinidad\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DEV SAPIEN Blog - Tools for IT Success\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-07-19T13:00:40+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-07-31T17:30:13+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#blogposting\",\"name\":\"New Video \\u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog\",\"headline\":\"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs\",\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/max_t\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.sapien.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/PS2018_AzureJob_01_2018-07-16_17-48-17-300x180.jpg\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#articleImage\"},\"datePublished\":\"2018-07-19T06:00:40-07:00\",\"dateModified\":\"2018-07-31T10:30:13-07:00\",\"inLanguage\":\"en-US\",\"commentCount\":3,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#webpage\"},\"articleSection\":\"PowerShell, PowerShell Core, PowerShell Studio, PrimalScript, PSCore6, Windows PowerShell, powershell, PowerShell Core, PowerShell Studio, PrimalScript, Windows PowerShell\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"position\":2,\"name\":\"Software News\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalscript-software-news\\\/#listItem\",\"name\":\"PrimalScript\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalscript-software-news\\\/#listItem\",\"position\":3,\"name\":\"PrimalScript\",\"item\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalscript-software-news\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#listItem\",\"name\":\"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/#listItem\",\"name\":\"Software News\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#listItem\",\"position\":4,\"name\":\"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/topics\\\/software-news\\\/primalscript-software-news\\\/#listItem\",\"name\":\"PrimalScript\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/max_t\\\/#author\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/max_t\\\/\",\"name\":\"Max Trinidad\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#webpage\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/\",\"name\":\"New Video \\u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog\",\"description\":\"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/2018\\\/07\\\/19\\\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/max_t\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/author\\\/max_t\\\/#author\"},\"datePublished\":\"2018-07-19T06:00:40-07:00\",\"dateModified\":\"2018-07-31T10:30:13-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/\",\"name\":\"DEV SAPIEN Blog\",\"description\":\"Tools for IT Success\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dev.sapien.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog","description":"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing","canonical_url":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#blogposting","name":"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog","headline":"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs","author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/max_t\/#author"},"publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/07\/PS2018_AzureJob_01_2018-07-16_17-48-17-300x180.jpg","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#articleImage"},"datePublished":"2018-07-19T06:00:40-07:00","dateModified":"2018-07-31T10:30:13-07:00","inLanguage":"en-US","commentCount":3,"mainEntityOfPage":{"@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#webpage"},"isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#webpage"},"articleSection":"PowerShell, PowerShell Core, PowerShell Studio, PrimalScript, PSCore6, Windows PowerShell, powershell, PowerShell Core, PowerShell Studio, PrimalScript, Windows PowerShell"},{"@type":"BreadcrumbList","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/dev.sapien.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","position":2,"name":"Software News","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/#listItem","name":"PrimalScript"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/#listItem","position":3,"name":"PrimalScript","item":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#listItem","name":"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/#listItem","name":"Software News"}},{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#listItem","position":4,"name":"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs","previousItem":{"@type":"ListItem","@id":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/#listItem","name":"PrimalScript"}}]},{"@type":"Organization","@id":"https:\/\/dev.sapien.com\/blog\/#organization","name":"DEV SAPIEN Blog","description":"Tools for IT Success","url":"https:\/\/dev.sapien.com\/blog\/"},{"@type":"Person","@id":"https:\/\/dev.sapien.com\/blog\/author\/max_t\/#author","url":"https:\/\/dev.sapien.com\/blog\/author\/max_t\/","name":"Max Trinidad"},{"@type":"WebPage","@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#webpage","url":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/","name":"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog","description":"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dev.sapien.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/#breadcrumblist"},"author":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/max_t\/#author"},"creator":{"@id":"https:\/\/dev.sapien.com\/blog\/author\/max_t\/#author"},"datePublished":"2018-07-19T06:00:40-07:00","dateModified":"2018-07-31T10:30:13-07:00"},{"@type":"WebSite","@id":"https:\/\/dev.sapien.com\/blog\/#website","url":"https:\/\/dev.sapien.com\/blog\/","name":"DEV SAPIEN Blog","description":"Tools for IT Success","inLanguage":"en-US","publisher":{"@id":"https:\/\/dev.sapien.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"DEV SAPIEN Blog - Tools for IT Success","og:type":"article","og:title":"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog","og:description":"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing","og:url":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/","article:published_time":"2018-07-19T13:00:40+00:00","article:modified_time":"2018-07-31T17:30:13+00:00","twitter:card":"summary_large_image","twitter:title":"New Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs - DEV SAPIEN Blog","twitter:description":"Our latest video shows two different ways to execute a console AzureRM script as a job using PowerShell Studio 2018. In this short video we demonstrate how to use the Azure cmdlet Stop-AzureRmVM to stop an Azure VM by submitting the script code as a background job in two different ways: 1. Create the scriptblock containing"},"aioseo_meta_data":{"post_id":"15431","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-08-28 16:07:44","updated":"2026-08-28 16:07:44"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/\" title=\"Software News\">Software News<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/\" title=\"PrimalScript\">PrimalScript<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tNew Video \u2013 PowerShell Studio: Working with Azure cmdlets in Background Jobs\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dev.sapien.com\/blog"},{"label":"Software News","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/"},{"label":"PrimalScript","link":"https:\/\/dev.sapien.com\/blog\/topics\/software-news\/primalscript-software-news\/"},{"label":"New Video &#8211; PowerShell Studio: Working with Azure cmdlets in Background Jobs","link":"https:\/\/dev.sapien.com\/blog\/2018\/07\/19\/new-video-powershell-studio-working-with-azure-cmdlets-in-background-jobs\/"}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=15431"}],"version-history":[{"count":17,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15431\/revisions"}],"predecessor-version":[{"id":15666,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15431\/revisions\/15666"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=15431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=15431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=15431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}