Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Install-Module Microsoft.Graph.Beta -Scope AllUsers -Repository PSGallery -Force 1 produces:

Install-Module: Administrator rights are required to install modules in '/usr/local/share/powershell/Modules'. Log on to the computer with an account that has Administrator rights, and then try again, or install '/home/RokeJulianLockhart/.local/share/powershell/Modules' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

How is this applicable to pwsh? (Should I invoke it as UID 0?)

Footnotes

  1. microsoft/Partner-Center-DotNet-Samples/issues/131#issuecomment-4275706455

You must be logged in to vote

@RokeJulianLockhart you are running PowerShell 7.5.4 which as I mentioned in this comment comes with the new Microsoft.PowerShell.PSResourceGet module that replaces PowerShellGet (the module that Install-Module comes from) and has lots more improved features and is being actively developed.

So I kindly ask

  • Please Stop using Install-Module & the PowerShellGet module
    • Ideally on every system that you use PowerShell, whether that be Windows PowerShell (v5.1) or PowerShell (v7.x)
  • Please Start using Install-PSResource instead & the Microsoft.PowerShell.PSResourceGet module
  • Please Update scripts & any documentation you maintain that suggests or uses Install-Module

I also strongly recommend …

Replies: 3 comments · 2 replies

Comment options

That was the solution:

  1. #!/usr/bin/env -S pwsh -File
    $ProcessPath = (Get-Process -Id $PID).Path
    If ($ProcessPath -Match 'dotnet') { $CorrectPath = (Get-Command pwsh).Source }
    Else { $CorrectPath = $ProcessPath }
    run0 $CorrectPath

    1

  2. PowerShell 7.5.4
    PS /home/RokeJulianLockhart> Install-Module Microsoft.Graph.Beta -Scope AllUsers -Repository PSGallery
    
    Untrusted repository
    You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

    2

However, it doesn't resolve my superordinate problem:

PS /home/RokeJulianLockhart> Install-Module Microsoft.Graph.Beta -Scope AllUsers -Repository PSGallery
PS /home/RokeJulianLockhart> Get-InstalledModule Microsoft.Graph                                      
Get-Package: No match was found for the specified search criteria and module names 'Microsoft.Graph'.
PS /home/RokeJulianLockhart> Import-Module Microsoft.Graph.Beta                                       
Import-Module: The required module 'Microsoft.Graph.Applications' is not loaded. Load the module or remove the module from 'RequiredModules' in the file '/usr/local/share/powershell/Modules/Microsoft.Graph.Beta/2.36.1/Microsoft.Graph.Beta.psd1'.
PS /home/RokeJulianLockhart> Remove-Module Microsoft.Graph.Beta
Remove-Module: No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.

Footnotes

  1. bugzilla.redhat.com/show_bug.cgi?id=2459501

  2. Azure/azure-powershell/issues/17210#issuecomment-4275691468

You must be logged in to vote
0 replies
Comment options

@RokeJulianLockhart you are running PowerShell 7.5.4 which as I mentioned in this comment comes with the new Microsoft.PowerShell.PSResourceGet module that replaces PowerShellGet (the module that Install-Module comes from) and has lots more improved features and is being actively developed.

So I kindly ask

  • Please Stop using Install-Module & the PowerShellGet module
    • Ideally on every system that you use PowerShell, whether that be Windows PowerShell (v5.1) or PowerShell (v7.x)
  • Please Start using Install-PSResource instead & the Microsoft.PowerShell.PSResourceGet module
  • Please Update scripts & any documentation you maintain that suggests or uses Install-Module

I also strongly recommend that you don't run Import-Module Microsoft.Graph.Beta and instead import only what parts of the Microsoft.Graph modules that you actually need.
That said, you can normally rely on the Module Autoloading behaviour that happens when calling exported commands from those modules, though this isn't always the case with some badly authored modules out there.

How is this applicable to pwsh? (Should I invoke it as UID 0?)

Yes as you found out - though this is only needed if you are intending to install modules on a machine with multiple users on it, when using -Scope AllUsers & isn't needed if only installing for a single user with -Scope CurrentUser

hope that helps

You must be logged in to vote
2 replies
@roke-julian-lockhart
Comment options

You are running PowerShell 7.5.4, which as I mentioned in this comment, comes with the new Microsoft.PowerShell.PSResourceGet module that replaces PowerShellGet (the module that Install-Module comes from) and has lots more improved features, and is being actively developed.

So, I kindly ask:

  • Please stop using Install-Module & the PowerShellGet module.

  • Ideally, on every system that you use PowerShell, whether that be Windows PowerShell (v5.1) or PowerShell (v7.x):

    • Please Start using Install-PSResource instead & the Microsoft.PowerShell.PSResourceGet module.

    • Please Update scripts & any documentation you maintain that suggests or uses Install-Module.

I also strongly recommend that you don't run Import-Module Microsoft.Graph.Beta and instead import only what parts of the Microsoft.Graph modules that you actually need.

@kilasuit, I was adhering to learn.microsoft.com/en-us/powershell/microsoftgraph/installation?view=graph-powershell-beta when I invoked the aforecited commands. Are those able to be updated?

@kilasuit
Comment options

I expect that in time they will be as currently whilst these are recommendations that I strongly stuggest are followed (based on the direction the team are taking going forward) there are some issues with this being the native defaults whilst PowerShell 5.1 doesn't have PSResourceGet installed with it by default.

Perhaps @sdwheeler knows who to reach out to in the team that looks after those docs as this isn't something that the PowerShell team manage

Answer selected by roke-julian-lockhart
Comment options

Please file issues for PSResourceGet in https://github.com/PowerShell/PSResourceGet/issues. The problem may be with the Microsoft.Graph.Beta module and not PowerShellGet or PSResourceGet.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.