Install PowerShell Module (Intersight) - Ubuntu

I have an Ubuntu installation running PowerShell Core 7.4.1

What are the pre-requisites for install modules from the PowerShell Gallery.

For example when the following commands are run I get the following errors

PS /home/nats_user/ps7_scripts> Get-PSRepository
WARNING: Unable to find module repositories.
PS /home/nats_user/ps7_scripts> Find-Package
WARNING: Query Url https://api.nuget.org/v3/index.json is invalid.

Or this

PS /home/nats_user/ps7_scripts> Install-Module -Name Intersight.PowerShell -RequiredVersion 1.0.11.13515
Install-Package: No match was found for the specified search criteria and module name ā€˜Intersight.PowerShell’. Try Get-PSRepository to see all available registered module repositories.

I can find plenty of documentation on how to install Powershell Core on a Linux Distro but unable to find any on how to configure it, it all seems Windows orientated.

I have an Ubuntu VM with PowerShell Core on it but I don’t remember doing anything special to register the repository.

Have you tried:

Register-PSRepository -Default

Of Course… same issues. I think I’m going back to Python

Your issue doesn’t appear to be related to powershell. It seems related to your Ubuntu system/networking. Look at this message

WARNING: Query Url https://api.nuget.org/v3/index.json is invalid.

You can put that URL in a browser and clearly see it’s valid. I’d fix your OS/networking before trying to use tools that require connectivity.

That’s why I am here. Asking for help to get Powershell Core working on an Ubuntu (Linux) system. PowerShell itself appears to be working, but no good if I can’t get additional module installed and working. As said there is very limited documentation around Ubuntu.

I would simply try uninstalling and reinstalling. You can blow away ~/.cache/powershell and ~/.config/powershell.

I use pwsh on Linux quite a bit and has never required any setup other than an install

You shouldn’t need to do anything, it should ā€˜just work’.
I just spun up a fresh Ubuntu instance, ran the code below and it worked as expected.

snap install powershell --classic
pwsh
Install-Module -Name Intersight.PowerShell -RequiredVersion 1.0.11.13515

I agree with Doug that this looks like a connectivity problem. If there’s no Internet connection available Register-PSRepository -Default will fail.

Can you browse the Internet on this machine?
Are you on a corporate network that has a firewall or proxy that might restrict Internet access?
What version of Ubuntu are you running?

If the system is headless/no GUI, you can use wget … something like this based on what Doug says. This might give you some clues.

wget https://api.nuget.org/v3/index.json

BTW, on my headless Ubuntu, this command works without issue.

Powershell is indeed working. Cmdlets that REQUIRE connectivity will not work if the connectivity is not working. Try the wget command from Tony as a first step to validate the ubuntu system has connectivity. Go from there.

Thank you all for the pointers, its very much appreciated. This is behind a Proxy and is configured correctly.

$wget https://api.nuget.org/v3/index.json
–2024-03-21 09:43:48-- https://api.nuget.org/v3/index.json
Connecting to x.x.x.x:3128… connected.
Proxy request sent, awaiting response… 200 OK
Length: 8789 (8.6K) [application/json]
Saving to: ā€˜index.json’

index.json 100%[=====================================================================================================================================>] 8.58K --.-KB/s in 0s

2024-03-21 09:43:51 (326 MB/s) - ā€˜index.json’ saved [8789/8789]

$ ls
index.json prod.list

Within Python when using pip to get packages you have to specify the --proxy variable. Is a similar thing required for Powershell 7? Are they extra steps required to be able to run ā€œRegister-PSRepositoryā€ command because its behind a Proxy?These I think are the additional steps that I am missing.

Not sure … but found this via google:

Or this:

Thank you so much. Again the examples are all Windows related but has now given me a pointer or two, especially that second example.