Windows Server 2016 – PowerShell import module permanently

First, we need to find the modules location.

$env:PSModulePath
or
Get-module -listavailable

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

I will copy the module to C:\Program Files\WindowsPowerShell\Modules. I assume you have downloaded the module and it is a zip file. So we copy the module to the location above

copy-item .\Docker.0.1.0.zip -Destination 'C:\Program Files\WindowsPowerShell\'

cd 'C:\Program Files\WindowsPowerShell\'

dir

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Expand-Archive .\Docker.0.1.0.zip -DestinationPath .\Docker 
#the directory name should be the same as the module without the .psm1
#the name is Docker.psm1 so the directory name should be Docker

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Now if you run

get-module -list available

you will see that the module is available to be imported from whatever location.

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Change your location and try to import it.

import-module docker

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Everything is working. Now we need to load it with every PowerShell run. Run PowerShell ISE and click the New icon, it is the first icon.

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Write

Import-Module Docker

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

Now save the script by clicking the 3rd icon. Choose the location of the file, c:\Windows\System32\WindowsPowerShell\v1.0\ and the filename should be profile.ps1

Now close all the PowerShell Windows and open one again. Try to write a Docker cmdlet to see if it is working.

I type Remove-ContainerImage and PowerShell can find it!!!

, <span>Windows Server 2016 – PowerShell import module permanently</span>, KandZ

 

It is working. Good luck !

 

 

32300cookie-checkWindows Server 2016 – PowerShell import module permanentlyWindows Server 2016 – PowerShell import module permanently

Related posts