{"id":257,"date":"2023-08-11T09:19:08","date_gmt":"2023-08-11T15:19:08","guid":{"rendered":"https:\/\/tekweis.com\/?p=257"},"modified":"2024-04-22T18:19:20","modified_gmt":"2024-04-23T00:19:20","slug":"download-files-from-website-via-powershell","status":"publish","type":"post","link":"https:\/\/tekweis.com\/index.php\/2023\/08\/11\/download-files-from-website-via-powershell\/","title":{"rendered":"Download files from website via Powershell"},"content":{"rendered":"\n<p>A simple method I like to use when I want to quickly run a powershell script to download a file from a webserver. I use this when endpoints are not on an internal network so a network share is not always available, but since I am usually remotely calling the powershell script, Internet access is established.<\/p>\n\n\n\n<p>The commandlet I use is <a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.utility\/invoke-restmethod?view=powershell-7.3\" data-type=\"link\" data-id=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.utility\/invoke-restmethod?view=powershell-7.3\"><strong>Invoke-RestMethod<\/strong><\/a>. I provide the source url for the file on a webserver to download and the destination, and I&#8217;m done. Extremely simple and extremely effective. There are so many ways to do this, but this is the method I personally use the most.<\/p>\n\n\n\n<p>The below example is what I have used to download the <a href=\"https:\/\/support.zoom.us\/hc\/en-us\/articles\/201362983-Uninstalling-and-reinstalling-the-Zoom-application\" data-type=\"link\" data-id=\"https:\/\/support.zoom.us\/hc\/en-us\/articles\/201362983-Uninstalling-and-reinstalling-the-Zoom-application\">CleanZoom utility from Zoom<\/a> that will remove any installed versions of Zoom on an endpoint, save the file in a temporary directory and then execute the utility.<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-pale-cyan-blue-background-color has-text-color has-background has-link-color has-small-font-size wp-elements-99dd3b119dfa569f0a83ffd7bb39cd5e\"><code>&lt;# --------------------------------------------------------------------------------\n\tUninstall all traces of Zoom from an endpoint.\n\n    Script downloads the CleanZoom.zip file from Zoom.com and then extracts it and\n    runs the utility.\n----------------------------------------------------------------------------------- #&gt;\n$src = 'https:\/\/assets.zoom.us\/docs\/msi-templates\/CleanZoom.zip'\n$dst = \"$env:TEMP\\CleanZoom.zip\"\nInvoke-RestMethod -Uri $src -OutFile $dst\nExpand-Archive -Path $dst -DestinationPath $env:TEMP -Force\n\nStart-Process $env:TEMP\\CleanZoom.exe -ArgumentList \"\/s\"\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A simple method I like to use when I want to quickly run a powershell script to download a file from a webserver. I use this when endpoints are not on an internal network so a network share is not always available, but since I am usually remotely calling the powershell script, Internet access is\u2026 <span class=\"read-more\"><a href=\"https:\/\/tekweis.com\/index.php\/2023\/08\/11\/download-files-from-website-via-powershell\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-257","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":5,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tekweis.com\/index.php\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}