Reputation: 23
I'm trying to run a script that uses Start-BitsTransfer
. However whenever I open Powershell I have to re-install the BitsTransfer
module each time. This also means that I cannot run scripts that call Powershell to run commands, since the module thinks it is not installed.
Upvotes: 2
Views: 3580
Reputation: 46730
If you want the module loaded every time just put that line import-module BitsTransfer
into one of the PowerShell profiles. From TechNet
%windir%\system32\WindowsPowerShell\v1.0\profile.ps1
This is for all users of the computer and for all shells.%windir%\system32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
This is for all users of the computer, but it is only for the Microsoft.PowerShell shell.%UserProfile%\Documents\WindowsPowerShell\profile.ps1
This is for the current user only and all shells.%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
This is for the current user only and only for the Microsoft.PowerShell shell.Note: The links above are cmd based environment variables and will not work directly in PowerShell. In PowerShell you would use the provider $env
. So for example:
$path = "$($env:windir)\system32\WindowsPowerShell\v1.0\profile.ps1"
# Assuming the directory '$($env:windir)\system32\WindowsPowerShell\v1.0' exists...
"Import-Module BitsTransfer" | Set-Content $path -Force
# This will OVERWRITE anything already there. This is just an example for reference.
Its not a case of installed..... it just needs to be imported. I do the same with the ActiveDirectory
module.
And as CB. says:
Beginning in Windows PowerShell 3.0, modules are imported automatically when any cmdlet or function in the module is used in a command. This feature works on any module in a directory that this included in the value of the
PSModulePath
environment variable.
Upvotes: 5