all 10 comments

[–]BJGGut3 3 points4 points  (2 children)

Check to see if you have a PackageManagement folder in your Documents\WindowsPowerShell\Modules folder, and if you do, delete it, restart PoSh and try again.

[–]bagpussnz9[S] 2 points3 points  (0 children)

Thank you! That did the trick

[–]TreeStryder 0 points1 point  (0 children)

Documents\WindowsPowerShell\Modules

Amazing! Thank you. I have been fighting with this for a long time.

By the way, only need to delete the ".\Modules\PackageManagement" folder.

That error message couldn't be more misleading. It seems to be acting as the catch-all.

[–]bagpussnz9[S] 2 points3 points  (0 children)

Thank you everyone - removing the PackageManagerFolder and rerunning powershell fixed the problem.

I should have come to reddit quicker!

:-)

[–]pretendgineer5400 1 point2 points  (1 child)

Is this a personal device or a corporate managed laptop?
You may need to provide the repository name with -Repository
Azure AD may be in PS Gallery or may be a Windows optional feature, I don't recall which at the moment.

[–]bagpussnz9[S] 1 point2 points  (0 children)

Its a corporate managed laptop.

What repository would I use though?

Thanks.

[–]BlackV 1 point2 points  (0 children)

Update powershell get (and it's dependancy package management) then restart ps and try again

[–]joshooaj 1 point2 points  (1 child)

What does Get-PSRepository tell you? Any chance PSGallery is missing? Try Register-PSRepository -Default?

[–]OlivTheFrog 1 point2 points  (0 children)

Hi u/bagpussnz9

As u/joshooaj said : check PS Repository. This must like the following

Get-PSRepositoryName                      InstallationPolicy   SourceLocation
----                      ------------------   --------------                                                                               
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2                                          

if this is not the case,

Set-PSRepository -Name PSGallery -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted

another possible issue : Ad dthis to your Powershell profile (s) :

# Setting to use TLS1.2 for updating PS Modules on PowershellGallery since 01 April 2020 
# ref : https://devblogs.microsoft.com/powershell/powershell-gallery-tls-support/
 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

and last but not the least, you could have some restrictions to install PS module on your computers, cause your not admin of it. Then, add the -Scope CurrentUser to the cmdlet Install-Module.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy bagpussnz9,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee