{"id":97894,"date":"2024-11-11T18:00:58","date_gmt":"2024-11-11T12:30:58","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=97894"},"modified":"2025-03-26T16:30:10","modified_gmt":"2025-03-26T11:00:10","slug":"azure-powershell-quick-setup-guide","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/","title":{"rendered":"Getting Started with Azure PowerShell: A Quick Setup Guide"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Azure PowerShell (Az PowerShell for short) is the product name for the collection of official Microsoft PowerShell command-line and scripting language modules that are used for managing and administering Azure resources. You can use Azure PowerShell interactively by running commands from PowerShell or creating and executing scripts that comprise multiple commands that control every aspect of Azure. It is deployed in the building of automated workflows using and runs on many platforms, including Linux, macOS, and Windows.\u00a0<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ea7e02;color:#ea7e02\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ea7e02;color:#ea7e02\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Heres_How_to_Run_Your_First_Script_Using_Azure_PowerShell_Follow_These_Steps\" >Here\u2019s How to Run Your First Script Using Azure PowerShell: Follow These Steps<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_1_Install_Azure_PowerShell\" >Step 1: Install Azure PowerShell<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_2_Access_Azure_PowerShell\" >Step 2: Access Azure PowerShell\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_3_Create_your_PowerShell_environment\" >Step 3: Create your PowerShell environment\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_4_Register_resource_provider\" >Step 4: Register resource provider\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_5_Find_commands\" >Step 5: Find commands:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_6_Create_a_new_file\" >Step 6: Create a new file.\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_7_Run_your_Script\" >Step 7: Run your Script\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_8_Verify_the_results\" >Step 8: Verify the results\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_9_Change_the_execution_policy_Optional\" >Step 9: Change the execution policy (Optional)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Step_10_Get_help\" >Step 10: Get help<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.whizlabs.com\/blog\/azure-powershell-quick-setup-guide\/#Conclusion\" >Conclusion\u00a0<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Heres_How_to_Run_Your_First_Script_Using_Azure_PowerShell_Follow_These_Steps\"><\/span><strong>Here\u2019s How to Run Your First Script Using Azure PowerShell: Follow These Steps<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"flex max-w-full flex-col flex-grow\">\n<div class=\"min-h-8 text-message flex w-full flex-col items-end gap-2 whitespace-normal break-words [.text-message+&amp;]:mt-5\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"2fb58cdb-dca6-4dbe-b207-26f85a7d1553\" data-message-model-slug=\"gpt-4o-mini\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[3px]\">\n<h3 class=\"markdown prose w-full break-words dark:prose-invert dark\"><span class=\"ez-toc-section\" id=\"Step_1_Install_Azure_PowerShell\"><\/span><strong>Step 1: Install Azure PowerShell<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p class=\"markdown prose w-full break-words dark:prose-invert dark\"><span style=\"font-weight: 400;\">The first step is to install Azure PowerShell, and then specify how to access and use it to manage your Azure resources. Ensure that you install the latest version of Azure PowerShell, that is, 12.4.0. However, any supported version of PowerShell version 7 or higher is recommended for use with the Az PowerShell module on all platforms. Follow these steps to install the Az PowerShell module, <\/span><\/p>\n<\/div>\n<\/div>\n<\/div>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Right-click the Start menu<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open Terminal and you get the Windows PowerShell window\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Run the Install-Module cmdlet at the end of the command line. Use Az for the Name parameter and append a Force switch at the end as follows: <\/span><strong>Install-Module -Name Az -Force<\/strong><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_2_Access_Azure_PowerShell\"><\/span><b>Step 2: Access Azure PowerShell\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Accessing the <\/span><a title=\"Azure Powershell\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/azure\/get-started-azureps?view=azps-12.4.0\" target=\"_blank\" rel=\"nofollow noopener\"><span style=\"font-weight: 400;\"><strong>Azure Powershell<\/strong><\/span><\/a><span style=\"font-weight: 400;\"> is the next step after a successful installation.\u00a0 This is achieved using the following 3 options namely: local access, Azure Cloud Shell access and Azure portal access.<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Local Access: <\/b><span style=\"font-weight: 400;\">This refers to accessing the Azure PowerShell for the local installation. Using this approach, follow the following steps:\u00a0<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Write the \u2018Connect-AZ Account\u2019 cmdlet. A Microsoft Azure icon will pop up.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"2\"><span style=\"font-weight: 400;\">Sign in to your Azure account and you now have access. <\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Azure Cloud Shell Access<\/b><span style=\"font-weight: 400;\">: Another option to access and connect is through Azure Cloud Shell. Azure Cloud Shell is a pre-installed browser-based environment that runs PowerShell on a Linux container, where Windows-specific features are not available. This allows you to run Azure PowerShell commands installing nothing on your local machine. To access;\u00a0<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Go to shell.azure.com. A Microsoft Azure icon will pop up and then;\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Sign in to your Azure account. You will now have access as shown below;<\/span><\/span><img decoding=\"async\" class=\"alignnone wp-image-97896 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-access-cloud-shell-directly.webp\" alt=\"azure access cloud shell directly\" width=\"955\" height=\"575\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-access-cloud-shell-directly.webp 955w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-access-cloud-shell-directly-300x181.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-access-cloud-shell-directly-768x462.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-access-cloud-shell-directly-150x90.webp 150w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Note that if you are logging in the first time logging in, the system will show a failure to mount the Azure file share.<\/span> <span style=\"font-weight: 400;\">If you proceed without mounting storage, Azure Cloud Shell your files will be ephemeral, and will not exist beyond your existing session. You, therefore, need to create storage either from PowerShell or Bash. To create storage.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select the Subscription used in creating the storage account<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select Create storage<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The above\u00a0 steps will cause Azure Cloud Shell\u00a0 to create for your use a standard storage account and allocate 5 GB of storage for the file share.\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Azure Portal<\/b><span style=\"font-weight: 400;\">: This is the easiest way to access Azure PowerShell, and you follow the following simple steps<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Go to the Azure portal.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Click on the menu in the top right-hand corner is a command-prompt icon as shown below, and it will open a shell at the bottom of the screen.<\/span><\/span><img decoding=\"async\" class=\"alignnone wp-image-97900 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal.webp\" alt=\"azure portal\" width=\"1262\" height=\"694\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal.webp 1262w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal-300x165.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal-1024x563.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal-768x422.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-portal-150x82.webp 150w\" sizes=\"(max-width: 1262px) 100vw, 1262px\" \/><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">As in Azure Cloud Shell access, you need to create storage either from PowerShell or Bash to enable your files to be stored in standard storage and not ephemeral storage. Follow the same stages.\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select the Subscription that was used to create the storage account<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select Create storage.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Azure Cloud Shell will create a storage account and allocate 5 GB and 100 GB of storage for\u00a0 standard and premium users respectively. Note that regardless of the method to connect, Azure PowerShell processes go through a single management interface called the Azure Resource Manager, whose purpose is to authenticate and allow all the actions you need to perform. For Azure PowerShell and the Azure Command-Line Interface, use a Software Development Kit (SDK), to connect to Azure Resource Manager and perform the required actions. Remember, the SDK is automatically installed as part of the Azure PowerShell Module.\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_3_Create_your_PowerShell_environment\"><\/span><b>Step 3: Create your PowerShell environment\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">After successfully signing in and creating storage, you then need to create the Azure PowerShell environment. You can choose between PowerShell and Bash for your command-line experience. You can also resize your environment as per your requirements.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_4_Register_resource_provider\"><\/span><b>Step 4: Register resource provider\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To start using Azure Cloud Shell, you must register with Microsoft. Cloud Shell resource provider to enable access to resources. To register;\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Start Azure Cloud Shell<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select your Subscription.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Under Settings, select Resource providers.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enter Cloud Shell in the search ox<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select the Microsoft.Cloud Shell resource provider.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select Register\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Change the status from unregistered to registered, as shown in the figure below.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-97902 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider.webp\" alt=\"azure cloudshell register resource provider\" width=\"1136\" height=\"743\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider.webp 1136w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider-300x196.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider-1024x670.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider-768x502.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-cloudshell-register-resource-provider-150x98.webp 150w\" sizes=\"(max-width: 1136px) 100vw, 1136px\" \/><br \/>\n<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_5_Find_commands\"><\/span><b>Step 5: Find commands: <\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">The next step is to use the cmdlets to manage your Azure resources. A cmdlet is the basic syntax that contains all the code needed in order to perform an action in Azure PowerShell. Cmdlets follow the standard PowerShell naming convention of Verb-Noun with the verb describing the action (e.g., New, Get, Set), while the noun represents the resource type such as AzKeyVaultCertificate, Firewall. Put simply, the interpretation is that the code is doing something (verb) to a thing (noun) thus making it easier to understand what the code is trying to do. Note that nouns in Azure PowerShell start must start with the \u2018Az\u2019 prefix. For example;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Get. AzResourceGroup cmdlet will return all the resource groups in your current Azure subscription.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The following is a list of the common Azure PowerShell resources and their associated modules.<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-97903 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules.webp\" alt=\"common azure powershell resources and their associated modules\" width=\"1536\" height=\"927\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules-300x181.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules-1024x618.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules-768x464.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/common-azure-powershell-resources-and-their-associated-modules-150x91.webp 150w\" sizes=\"(max-width: 1536px) 100vw, 1536px\" \/><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Cmdlets also have parameters to gather information in order to perform the required actions. You can scroll through all the different parameters that are available and choose the required one. In Azure PowerShell, you can enclose strings in either single quotation marks (&#8221;) or double quotation marks (\u201c\u201d) as both methods allow Azure PowerShell to display variable values instead of variable names.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_6_Create_a_new_file\"><\/span><b>Step 6:<\/b> <b>Create a new file.\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Use any text editor such as Notepad to create a new Azure PowerShell script file. Follow the following steps.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Create a new file\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Name the file \u2018First Script\u2019<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Save the file with a. ps1 extension, that is, FirstScript.ps1 after writing your commands<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-97904 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file.webp\" alt=\"create a new Azure Powershell script file\" width=\"1647\" height=\"872\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file.webp 1647w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file-300x159.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file-1024x542.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file-768x407.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file-1536x813.webp 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/create-a-new-azure-powershell-script-file-150x79.webp 150w\" sizes=\"(max-width: 1647px) 100vw, 1647px\" \/><br \/>\n<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Return to the Azure PowerShell window<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">NOTE: You can also follow the longstanding tradition among software engineers of typing the phrase \u201cHello World\u201d to a command line.\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_7_Run_your_Script\"><\/span><b>Step 7: Run your Script\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">To run the script, the most common method is to call it in the Azure PowerShell terminal, and you can use the PowerShell ISE or VS CodeVS Code for this purpose. Use the following steps.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open Azure PowerShell\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Type in the Code: Write-Host \u201cFirstScript!\u201d<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The results will be : FirstScript as shown below (Last line);<br \/>\n<img decoding=\"async\" class=\"alignnone wp-image-97905 size-full\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script.webp\" alt=\"az run your script\" width=\"1412\" height=\"616\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script.webp 1412w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script-300x131.webp 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script-1024x447.webp 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script-768x335.webp 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/az-run-your-script-150x65.webp 150w\" sizes=\"(max-width: 1412px) 100vw, 1412px\" \/><br \/>\n<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_8_Verify_the_results\"><\/span><b>Step 8: Verify the results\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">The output of the script \u201cFirst Script\u201d will be displayed in the Azure PowerShell terminal. Verify the output in the Azure PowerShell window to see if it is your desired output.\u00a0\u00a0<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Step_9_Change_the_execution_policy_Optional\"><\/span><b>Step 9:<\/b> <b>Change the execution policy (Optional)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Azure PowerShell enforces an <a title=\"execution policy\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.core\/about\/about_execution_policies?view=powershell-7.4\" target=\"_blank\" rel=\"nofollow noopener\"><strong>execution policy<\/strong><\/a> to prevent malicious scripts from running. To use our newly created script, change your execution policy to allow our Azure PowerShell script to run. The following are the categories of execution policies that control security and the ability to execute scripts:\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Restricted<\/b><span style=\"font-weight: 400;\">: This is the default execution policy for Azure PowerShell and means that scripts are disabled. This means that only interactive commands can be executed on the console, which provides enhanced security.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>RemoteSigned: <\/b><span style=\"font-weight: 400;\">Using this method, locally created scripts may run while those created on another machine are restricted. They are only allowed to run when a trusted publisher signs them. This method allows the local scripts to be used with ease.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>AllSigned<\/b><span style=\"font-weight: 400;\">: All scripts are only allowed to run if a trusted publisher digitally signs them. This therefore entails the author using a digital certificate to sign the script.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Unrestricted<\/b><span style=\"font-weight: 400;\">: All scripts run regardless of their creator and whether they are signed or not. This is the least secure of the methods and is not recommended as it poses security risks. However, the method can be used for testing purposes.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">You can view the current execution policy in your Azure PowerShell environment using the Get-ExecutionPolicy command. Use the Set-ExecutionPolicy command to change the current execution policy to the policy you want. If you have not digitally signed your PowerShell script, your options for the execution policy will be limited to RemoteSigned and Unrestricted. If the <strong><a title=\"SetExecutionPolicy\" href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.security\/set-executionpolicy?view=powershell-7.4\" target=\"_blank\" rel=\"nofollow noopener\">SetExecutionPolicy<\/a> <\/strong>cmdlet asks you to verify that you really want to change the execution policy, select Y for yes and then close and reopen your PowerShell window.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To change the execution policy;<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Reopen Azure PowerShell as an administrator<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Run the command: Set-ExecutionPolicy RemoteSigned<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Step_10_Get_help\"><\/span><b>Step 10: Get help<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">One of the most crucial advantages of Azure PowerShell is that it always provides help whenever it is required. To get help, simply enter Get-Help and then the cmdlet you want to get help on, and assistance is immediately provided.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><b>Conclusion\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The above steps explained how to write and run your Azure PowerShell script in quite an uncomplicated way. The major takeaway of these steps is the simplicity of the scripting language and process. Where other languages require every character, PowerShell is more relaxed in that regard. For example, the language is case-insensitive, and accidental typing type, an upper- or lowercase letter, will not affect the results. However, you should always be on the lookout for misspellings and any extra or missing spaces. Always check for spelling of the name and path that was included, as reading, and correcting these errors are essential in helping you learn what caused them. The good thing is that with Azure, PowerShell, as you run a program and get an error, the error is often accompanied by the number where the issue occurred, a description of the error, and sometimes a suggestion for how to fix it, simplifying the error resolution process.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you are preparing for <\/span><strong><a title=\"AZ-104: Microsoft Azure Administrator\" href=\"https:\/\/www.whizlabs.com\/microsoft-azure-certification-az-104\/\" target=\"_blank\" rel=\"noopener\">AZ-104: Microsoft Azure Administrator <\/a><\/strong><span style=\"font-weight: 400;\">Certification, it&#8217;s important to learn about Powershell in order to deploy the resources through the Azure CLI and help in automating the infrastructure. Do try the above Powershell commands in our <\/span><a title=\"Azure Sandbox\" href=\"https:\/\/www.whizlabs.com\/azure-sandbox\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\"><strong>Azure Sandbox<\/strong><\/span><\/a> <span style=\"font-weight: 400;\">\u00a0Environment.<\/span><span style=\"font-weight: 400;\">This practical experience will enhance your skills and provide the knowledge necessary to help you clear your certification exams.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure PowerShell (Az PowerShell for short) is the product name for the collection of official Microsoft PowerShell command-line and scripting language modules that are used for managing and administering Azure resources. You can use Azure PowerShell interactively by running commands from PowerShell or creating and executing scripts that comprise multiple commands that control every aspect of Azure. It is deployed in the building of automated workflows using and runs on many platforms, including Linux, macOS, and Windows.\u00a0 Here\u2019s How to Run Your First Script Using Azure PowerShell: Follow These Steps Step 1: Install Azure PowerShell The first step is to [&hellip;]<\/p>\n","protected":false},"author":436,"featured_media":97914,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[15],"tags":[349,1073],"class_list":["post-97894","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-azure","tag-azure","tag-microsoft-azure"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide.webp",1536,864,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-150x150.webp",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-300x169.webp",300,169,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-768x432.webp",768,432,true],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-1024x576.webp",1024,576,true],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide.webp",1536,864,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide.webp",1536,864,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-24x24.webp",24,24,true],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-48x48.webp",48,48,true],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-96x96.webp",96,96,true],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-150x150.webp",150,150,true],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-300x300.webp",300,300,true],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-250x250.webp",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-640x853.webp",640,853,true],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2024\/11\/azure-powershell-quick-setup-guide-150x84.webp",150,84,true]},"uagb_author_info":{"display_name":"Swetha Selvakumar","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/swetha-selvakumar\/"},"uagb_comment_info":1,"uagb_excerpt":"Azure PowerShell (Az PowerShell for short) is the product name for the collection of official Microsoft PowerShell command-line and scripting language modules that are used for managing and administering Azure resources. You can use Azure PowerShell interactively by running commands from PowerShell or creating and executing scripts that comprise multiple commands that control every aspect&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/97894","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/436"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=97894"}],"version-history":[{"count":11,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/97894\/revisions"}],"predecessor-version":[{"id":98325,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/97894\/revisions\/98325"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/97914"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=97894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=97894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=97894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}