{"id":122,"date":"2021-10-14T14:09:34","date_gmt":"2021-10-14T14:09:34","guid":{"rendered":"https:\/\/ouritsource.com\/blog\/?p=122"},"modified":"2021-10-14T14:32:06","modified_gmt":"2021-10-14T14:32:06","slug":"example-of-mapping-to-an-azure-drive-using-powershell","status":"publish","type":"post","link":"https:\/\/ouritsource.com\/blog\/example-of-mapping-to-an-azure-drive-using-powershell\/","title":{"rendered":"Example of Mapping to an Azure Drive Using PowerShell"},"content":{"rendered":"<body>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"318\" height=\"159\" src=\"https:\/\/i0.wp.com\/ouritsource.com\/blog\/wp-content\/uploads\/2021\/10\/image-37.png?resize=318%2C159&#038;ssl=1\" alt=\"\" class=\"wp-image-129\" loading=\"lazy\" srcset=\"https:\/\/i0.wp.com\/ouritsource.com\/blog\/wp-content\/uploads\/2021\/10\/image-37.png?w=318&amp;ssl=1 318w, https:\/\/i0.wp.com\/ouritsource.com\/blog\/wp-content\/uploads\/2021\/10\/image-37.png?resize=300%2C150&amp;ssl=1 300w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/figure>\n\n\n\n<p>Below is an example of a PowerShell script that maps to an Azure share. It first checks to see if it can see the server (IE: eu2windowshare.file.core.windows.net)  then proceeds with storing credentials into credential manager before proceeding to map a drive to the Azure share.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color\">$connectTestResult = Test-NetConnection -ComputerName eus2windowshare.file.core.windows.net -Port 445<br><br>if ($connectTestResult.TcpTestSucceeded) {<br>      # Save the password so the drive will persist on reboot<br>      cmd.exe \/C \u201ccmdkey \/add:`\u201deus2windowshare.file.core.windows.net`\u201d \/user:`\u201dlocalhost\\eus2usernameforshare`\u201d  \/pass:`\u201dZ==eresheh3353yhfb5u2rthdfg62==`\u201d\u201d<br>      <br>       # Mount the drive<br>      New-PSDrive -Name Z -PSProvider FileSystem -Root \u201c\\\\eus2windowshare.file.core.windows.net\\share\u201d -Persist<br>      }  <br>else <br>     {<br>       Write-Error -Message \u201cUnable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port.\u201d<br>     }<\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>Below is an example of a PowerShell script that maps to an Azure share. It first checks to see if it can see the server (IE: eu2windowshare.file.core.windows.net) then proceeds with storing credentials&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[19],"tags":[],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-windows-powershell","no-thumbnail"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":4,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/posts\/122\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ouritsource.com\/blog\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}