问题
I'm running Windows 7 with PowerShell 2 installed.
I've downloaded version 2.1 from here - http://pscx.codeplex.com/releases
The Release notes say
- unblock the zip file - {which I did}
- extract the contents of the ZIP file to your $env:Home\Documents\WindowsPowerShell\Modules folder
I was unsure what $env:Home was so a bit of searching determined that the release notes are expecting an environment variable called Home which doesn't exist on my machine.
A bit more searching says use what is defined as ~
on my machine. So in a PS prompt I run cd ~
Which on my machine led to a network drive U:
I created the following directories U:\Documents\WindowsPowerShell\Modules
and copied the extracted Pscx-2.1.0 to the Modules folder. Opened a PowerShell prompt and typed Get-Module -ListAvailable
. This didn't give me Pscx in the results.
The above steps actually gave me this folder tree U:\Documents\WindowsPowerShell\Modules\Pscx-2.1.0\Pscx-2.1.0
So I copied the files up a level and tried again with U:\Documents\WindowsPowerShell\Modules\Pscx-2.1.0\
and also tried with U:\Documents\WindowsPowerShell\Modules\Pscx\
I also tried all of the above with this path U:\WindowsPowerShell\Modules\Pscx-2.1.0\
I'm guessing that the Modules aren't actually supposed to be in this directory, so a bit more searching leads to this command. (Get-ChildItem Env:\PSModulePath).Value
which gives the following result
C:\Users\my.name\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
So I copy the Pscx-2.1.0 folder to here C:\Users\my.name\Documents\WindowsPowerShell\Modules\Pscx-2.1.0
And still no luck.
What step am I missing?
回答1:
I hadn't actually completed the last step of my above question completely which turned out to be the answer.
Here is that answer for completeness
- Unblock the zip file you have downloaded
- extract the zip file - this will likely give a folder structure of
Pscx-2.1.0/Pscx-2.1.0/{lots of files}
- rename the child folder to Pscx - ie -
Pscx-2.1.0/Pscx/{lots of files}
- In Powershell prompt run
(Get-ChildItem Env:\PSModulePath).Value
and note the modules folder location. - Copy the child
Pscx folder
to the Modules folder location given above. - In Powershell prompt run Get-Module -ListAvailable to see the Pscx module available.
回答2:
In PowerShell 5.0, you can do:
Find-Package pscx | ? ProviderName -eq PSModule | Install-Package -Force
The -Force
parameter will cause it to upgrade if an older version is already installed.
In PowerShell 5.1, you'll need:
Find-Package pscx | ? ProviderName -eq PowerShellGet | Install-Package -Force
or
Find-Package pscx -ProviderName PowerShellGet | Install-Package -Force
or just
Install-Package pscx -Force
回答3:
Just run
choco install pscx
See chocolatey.org for a one-liner to get the choco
command.
Keep in mind you may still have to call this in your scripts before running their commands:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser #allows scripts to run from the interwebs, such as pcsx
回答4:
You can also use PsGet to easily search and install PowerShell modules.
You can check which modules have been added to PsGet by browsing for all modules:
> Get-PsGetModuleInfo *
Or locate this one specfically:
> Get-PsGetModuleInfo pscx
Then you can install based on that information:
> Install-Module pscx
回答5:
After spending lot of time searching here and there, i found this blog has very clear steps to solve. try it may helps u ..
http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/18/install-the-pscx-and-80-new-cmdlets-to-ease-powershell-use.aspx
来源:https://stackoverflow.com/questions/13755082/how-do-i-install-pcsx-powershell-module