{"id":5406,"date":"2018-04-22T23:49:10","date_gmt":"2018-04-22T21:49:10","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=5406"},"modified":"2018-04-23T13:17:24","modified_gmt":"2018-04-23T11:17:24","slug":"powershell-transfer-modules-to-an-offline-pc","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/powershell-transfer-modules-to-an-offline-pc\/","title":{"rendered":"Powershell: Transfer Modules to an offline PC"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_5406 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_5406')){$('.twoclick_social_bookmarks_post_5406').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Powershell%3A%20Transfer%20Modules%20to%20an%20offline%20PC\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Ain%20these%20days%20powershell%20modules%20are%20often%20installed%20from%20a%20%28NuGet%29%20Repository%20and%20not%20by%20a%20Setup%20program.%0D%0A%0D%0AIn%20companies%20may%20exists%20computers%20which%20does%20not%20have%20an%20active%20internet%20connection.%0D%0A%0D%0ABut%20how%20to%20install%20the%20modules%20on%20these%20devices%3F%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/powershell-transfer-modules-to-an-offline-pc\\\/\",\"post_id\":5406,\"post_title_referrer_track\":\"Powershell%3A+Transfer+Modules+to+an+offline+PC\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>in these days powershell modules are often installed from a (NuGet) Repository and not by a Setup program.<\/p>\n<p>In companies may exists computers which does not have an active internet connection.<\/p>\n<p>But how to install the modules on these devices?<br \/>\n<!--more--><\/p>\n<p>It&#8217;s possible by simply coping some folders \ud83d\ude42 <\/p>\n<p>In this example I will install the VMware PowerCli Modules<\/p>\n<p>First install the modules on an PC which is similar (OS, Architecture) to the offline PC&#8217;s. I&#8217;ve already <a href=\"https:\/\/michlstechblog.info\/blog\/vmware-installing-powercli\/\" rel=\"noopener\" target=\"_blank\">described this process<\/a>.<\/p>\n<p>Then locate the modules in the filesystem. Powershell has multiple folders where modules are installed to. This &#8220;oneliner&#8221; list all subfolders under the Powershell module locations:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; $env:PSModulePath.Split(&quot;;&quot;) | %{if(Test-Path $_){get-Item ($_+&quot;\\*&quot;)}}\r\n\r\n    Verzeichnis: C:\\Program Files\\WindowsPowerShell\\Modules\r\n\r\n\r\nMode                LastWriteTime         Length Name\r\n...\r\nd-----       22.04.2018     21:54                VMware.VimAutomation.Cloud\r\nd-----       22.04.2018     21:51                VMware.VimAutomation.Common\r\nd-----       22.04.2018     21:52                VMware.VimAutomation.Core\r\nd-----       22.04.2018     21:54                VMware.VimAutomation.HA\r\n...\r\n<\/pre>\n<p>Find the modules you want to transfer and copy all Modules folders to the new machine in the same folder <strong>&#8220;C:\\Program Files\\WindowsPowerShell\\Modules&#8221;<\/strong>. In this example all folders started with VMware. <\/p>\n<p>When the copy process has finished close all powershell instances at the &#8220;offline&#8221; PC and reopen it. Powershell reads all module information at startup.<\/p>\n<p>Check if modules are found<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Get-Module -ListAvailable\r\n\r\n\r\n    Directory: C:\\Program Files\\WindowsPowerShell\\Modules\r\n\r\n\r\nModuleType Version    Name\r\n---------- -------    ----\r\n...\r\nScript     6.5.2.7... VMware.DeployAutomation\r\nScript     6.5.2.7... VMware.ImageBuilder\r\nManifest   10.0.0.... VMware.PowerCLI\r\nScript     10.0.0.... VMware.VimAutomation.Cis.Core\r\nScript     10.0.0.... VMware.VimAutomation.Cloud\r\nScript     10.0.0.... VMware.VimAutomation.Common\r\nScript     10.0.0.... VMware.VimAutomation.Core\r\n...\r\n<\/pre>\n<p>Then try to load the module(s).<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Import-Module VMware.PowerCLI\r\n<\/pre>\n<p>In case of VMware PowerCli and no internet connection is available it can happens that the connect to the vCenter takes a long time and then fails when the Server Certificate cannot verified.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Connect-VIServer yourVcenter.yourDomain.org\r\nConnect-VIServer : 22.04.2018 22:57:59  Connect-VIServer                Error: Invalid server certificate. Use\r\nSet-PowerCLIConfiguration to set the value for the InvalidCertificateAction option to Prompt if you'd like to connect\r\nonce or to add a permanent exception for this server.\r\n<\/pre>\n<p>If this occures you have no other option as to disable the certificate check.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nPS D:\\&gt; Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Scope AllUsers -Confirm:$false\r\n<\/pre>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, in these days powershell modules are often installed from a (NuGet) Repository and not by a Setup program. In companies may exists computers which does not have an active internet connection. But how to install the modules on these devices?<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[344,7,5,4],"tags":[153,394,1171,208,57,133,1170],"class_list":["post-5406","post","type-post","status-publish","format-standard","hentry","category-powershell-scripting","category-vmware","category-windowsknowhow","category-windowsscripts","tag-copy","tag-export","tag-import","tag-modules","tag-offline","tag-powershell","tag-transfer"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=5406"}],"version-history":[{"count":14,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5406\/revisions"}],"predecessor-version":[{"id":5421,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5406\/revisions\/5421"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=5406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=5406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=5406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}