Forum Discussion
Microsoft Graph PowerShell SDK Module OneDrive Folder Permissions Assignment
$permission = New-MgDriveItemPermission -RoleId "Contributor" -PrincipalId $userUPN
I end up getting the following error:
New-MgDriveItemPermission: A parameter cannot be found that matches parameter name 'RoleId'.
$permission = New-MgUserDriveItemPermission -Roles "Contribute" -UserId $userUPN
cmdlet New-MgUserDriveItemPermission at command pipeline position 1
Supply values for the following parameters:
DriveId: $adminDriveId
DriveItemId: 1
New-MgUserDriveItemPermission_CreateExpanded: The request URI is not valid. Since the segment 'drives' refers to a collection, this must be the last segment in the request URI or it must be followed by an function or action that can be bound to it otherwise all intermediate segments must refer to a single resource.
Status: 400 (BadRequest)
I looked at the documentation here:
https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.files/new-mguserdriveitempermission?view=graph-powershell-1.0
And changed the parameters to Roles "Contribute" and UserId "email address removed for privacy reasons" and did not go well for me still. Any other suggestions or thoughts on this?
Hi ShaneGibson,
thanks for your update.
The error message New-MgDriveItemPermission: A parameter cannot be found that matches parameter name 'RoleId' indicates that you are using an older version of the Microsoft Graph PowerShell SDK Module.
Please upgrade to the latest version of the module and try again.
To upgrade the Microsoft Graph PowerShell SDK Module, you can use the following PowerShell command:
Update-Module Microsoft.Graph.PowerShell.SDK
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
- ShaneGibsonOct 04, 2023Copper ContributorI don't see a PowerShell Module or command for "Update-Module Microsoft.Graph.PowerShell.SDK", when I run it, it fails "Update-Module: Module 'Microsoft.Graph.PowerShell.SDK' was not updated because no valid module was found in the module directory. Verify that the module is located in the folder specified by $env:PSModulePath."...
I installed following this article which (See below link) and it only lists the Install and Update commands like this "Install-Module Microsoft.Graph" & "Update-Module Microsoft.Graph" and I have the latest version of that PS Module.
Can you send me the documentation link for where your recommended command "Update-Module Microsoft.Graph.PowerShell.SDK" came from, maybe I am using the wrong PS Module or looking in the wrong spot in the documentation for Microsoft Graph PowerShell Module?
https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation?view=graph-powershell-1.0- LeonPavesicOct 04, 2023Silver Contributor
Hi ShaneGibson,
thanks for your update, this documentation link you provided is correct.I apologize for the error in my previous response. The Update-Module Microsoft.Graph.PowerShell.SDK cmdlet does not exist.
To update the Microsoft Graph PowerShell SDK Module, you can use the following PowerShell command:
Update-Module Microsoft.Graph
This command will update the Microsoft Graph PowerShell SDK Module to the latest version, as well as any other Microsoft Graph modules that are installed on your system.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)