Score:0

Powershell Linux - Unable to install Module in Azure Ubuntu

cn flag

I'm trying to install the AZ module in the Ubuntu powershell of an Azure Linux server.

However, the powersheel could not find the PSGallery repository.

I suspect the DNS record retrieved by the server is incorrect because the IP address is given by trafficmanager.net.

I would appreciate it if someone could give some pointers how to solve this. Thank you.

Installation attempt:

# pwsh
PowerShell 7.3.4


PS /root> Install-Module -Name Az -Repository PSGallery -Force
Get-PackageSource: Unable to find repository 'PSGallery'. Use Get-PSRepository to see all available repositories.
PS /root> [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
PS /root> Register-PSRepository -Default -Verbose
VERBOSE: Performing the operation "Register Module Repository." on target "Module Repository 'PSGallery' () in provider 'PowerShellGet'.".
PS /root> Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Set-PSRepository: No repository with the name 'PSGallery' was found.

DNS query:

scs3:~$  nslookup www.powershellgallery.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
www.powershellgallery.com       canonical name = powershellgallerytrafficmanager.trafficmanager.net.
powershellgallerytrafficmanager.trafficmanager.net      canonical name = psg-prod-eastus.cloudapp.net.
Name:   psg-prod-eastus.cloudapp.net
Address: 172.174.17.44

# nslookup redhat.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   redhat.com
Address: 34.235.198.240
Name:   redhat.com
Address: 52.200.142.250

Some troubleshooting:

PS /root> Invoke-WebRequest 'https://www.powershellgallery.com/api/v2/'
Invoke-WebRequest: Resource temporarily unavailable

# curl -v https://www.powershellgallery.com/api/v2/
*   Trying 172.174.17.44:443...
* TCP_NODELAY set
* connect to 172.174.17.44 port 443 failed: Connection timed out
* Failed to connect to www.powershellgallery.com port 443: Connection timed out
* Closing connection 0
curl: (28) Failed to connect to www.powershellgallery.com port 443: Connection timed out
[root@scsdevvem02 22Jun2023 12:42:32  ~]
# pwsh
PowerShell 7.3.4
PS /root> [enum]::GetNames([Net.SecurityProtocolType])

SystemDefault
Ssl3
Tls
Tls11
Tls12
Tls13

After adding in /etc/hosts:

20.84.181.62 www.powershellgallery.com

PS /root> Install-Module -Name Az -Repository PSGallery -Force -verbose
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/7/Modules/PackageManagement/coreclr/netstandard2.0/Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/7/Modules/PackageManagement/coreclr/netstandard2.0/Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/7/Modules/PackageManagement/coreclr/netstandard2.0/Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/7/Modules/PackageManagement/coreclr/netstandard2.0/Microsoft.PackageManagement.NuGetProvider.dll
Get-PackageSource: Unable to find repository 'PSGallery'. Use Get-PSRepository to see all available repositories.

Last attempt.


# snap install powershell --classic
powershell 7.3.4 from Microsoft PowerShell✓ installed

# pwsh
-bash: /usr/bin/pwsh: No such file or directory

# /snap/bin/pwsh
PowerShell 7.3.4
PS /root> Install-Module -Name Az -Repository PSGallery -Force
Get-PackageSource: Unable to find repository 'PSGallery'. Use Get-PSRepository to see all available repositories.
PS /root> Get-PSRepository
WARNING: Unable to find module repositories.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.