{"id":4528,"date":"2020-04-15T01:12:57","date_gmt":"2020-04-15T01:12:57","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4528"},"modified":"2022-12-02T03:32:37","modified_gmt":"2022-12-02T03:32:37","slug":"intune-copy-file-using-powershell-to-the-computer-from-an-azure-blob-location","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/azure\/intune-copy-file-using-powershell-to-the-computer-from-an-azure-blob-location","title":{"rendered":"InTune &#8211; Copy file using PowerShell to the computer from an Azure Blob location"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li>Setup an Azure subscription if you haven\u2019t got this already, this will be used for Billing. The storage is under a 1$\/Month for 1 GB space&nbsp;<\/li>\n\n\n\n<li>Create a Storage Container in the right Azure Region with the correct redundancy ( Local Redundancy Storage in Cheaper ) . Use General Purpose V2!<\/li>\n\n\n\n<li>Create a Blob Container in this Storage Resource<\/li>\n\n\n\n<li>Use Storage Explorer to upload files here<br><br><img loading=\"lazy\" decoding=\"async\" width=\"252\" height=\"311\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965e2d0b24e.png\" alt=\"\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965e2d0b24e.png 252w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965e2d0b24e-243x300.png 243w\"><\/li>\n\n\n\n<li>Upload what file you would like to deploy<\/li>\n\n\n\n<li>Right click on the file and choose \u201cGet Shared Access Signatue\u201d<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"333\" height=\"362\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ca2545e7.png\" alt=\"\" class=\"wp-image-4525 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ca2545e7.png 333w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ca2545e7-276x300.png 276w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/figure>\n\n\n\n<p>I set a 100 Year Expiry , and leave access as Read Only<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"387\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ce643153.png\" alt=\"\" class=\"wp-image-4526 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ce643153.png 579w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965ce643153-300x201.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/figure>\n\n\n\n<p>It will give you URI and query string<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"591\" height=\"297\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965d2bd1041.png\" alt=\"\" class=\"wp-image-4527 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965d2bd1041.png 591w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965d2bd1041-300x151.png 300w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/figure>\n\n\n\n<p>Copy the URI ONLY up to the file name ( nothing after e.g. the example below )&nbsp; and put in $BlobUri<\/p>\n\n\n\n<p>Copy the FULL Query String and put in $Sas<\/p>\n\n\n\n<p>Change the Output Path which will need to exist with a trailing \\, this example I have used the Users Desktop<\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">#Variables ( Use the Azure Storage Explorer to get the URI ( Shared Access Signature ) of the file and copy the first part up to the file name in BlobURI and the Query String to the Sas) <br\/>#You will need a new Sas for each file<br\/><br\/>$BlobUri = \u2019https:\/\/xxxxx.blob.core.windows.net\/xxxxx\/1.jpg\u2019<br\/>$Sas = \u2019?sp=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\u2019<br\/>#Output Path with \\ on the end<br\/>$OutputPath = \u2019C:\\Users\\\u2019 + $env:UserName + \u2019\\Desktop\\\u2019<br\/><br\/><br\/><br\/>#Gets full Uri<br\/>$FullUri = &quot;$BlobUri$Sas&quot;<br\/>#Downloads file to outpath with correct file type and file found in BlobURI<br\/>(New-Object System.Net.WebClient).DownloadFile($FullUri, $OutputPath + ($BlobUri -split \u2019\/\u2019)[-1])<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div>\n\n\n\n<p>Deploy this powershell file via Device Config Scripts<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"289\" height=\"325\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965f4919306.png\" alt=\"\" class=\"wp-image-4531 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965f4919306.png 289w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2020\/04\/img_5e965f4919306-267x300.png 267w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>I set a 100 Year Expiry , and leave access as Read Only It will give you URI and query string Copy the URI ONLY up to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2092,2836],"tags":[3191,2331,1103,3192,2837],"class_list":["post-4528","post","type-post","status-publish","format-standard","hentry","category-azure","category-intune","tag-blob","tag-deploy","tag-download","tag-file-copy","tag-intune"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4528"}],"version-history":[{"count":2,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4528\/revisions"}],"predecessor-version":[{"id":6475,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4528\/revisions\/6475"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}