microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
701 stars 168 forks source link

Update-MgDeviceManagementManagedDeviceUser (Feature Request) #1404

Closed othyssen closed 1 year ago

othyssen commented 2 years ago

Microsoft.Graph.Devicemanagement Version 1.10.0

While Get-MgDeviceManagementManagedDeviceUser is working like a charm to retrieve the Primary User of an Intune device, there should be a simple command available to update the primary user, like

Update-MgDeviceManagementManagedDeviceUser -ManagedDeviceId "xxxx" -UserId "yyyyy"

as mentioned in Issue #634 there is New-MgDeviceManagementManagedDeviceUserByRef available but it requires to build a hash table within the script first.

othyssen commented 2 years ago

I tried various ways in Graph Explorer with POST to have have an idea how New-MgDeviceManagementManagedDeviceUserByRef is working but I'm ending up with "An error has occurred" or sometimes with "Write requests are only supported on contained entities or navigation properties with bindings." Nice example of the request body much appreciated

peombwa commented 2 years ago

Thanks for following up on this.

Unfortunately, this is one of those API that requires you to build a hash table with the id of the reference object to be added - New-MgDeviceManagementManagedDeviceUserByRef. The examples should ideally be available in https://docs.microsoft.com/en-us/graph/api/intune-devices-manageddevice-update?view=graph-rest-beta#example as other workloads do, but this is currently not the case.

As for the errors you are getting, please open a question/ticket at https://developer.microsoft.com/en-us/graph/support to get help from the API owners/workload owner.

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

othyssen commented 2 years ago

The documentation new-mgdevicemanagementmanageddeviceuserbyref isn't accessible anymore which makes it difficult to select the attributes for the hash table

peombwa commented 1 year ago

It looks like the workload owner removed the new-mgdevicemanagementmanageddeviceuserbyref API from the service schema:

➜ Find-MgGraphCommand -Uri "/deviceManagement/managedDevices/{managedDevice-id}/users.*"

   APIVersion: v1.0

Command                                 Module           Method URI                                                       OutputType          Permissions Variants
-------                                 ------           ------ ---                                                       ----------          ----------- --------
Get-MgDeviceManagementManagedDeviceUser DeviceManagement GET    /deviceManagement/managedDevices/{managedDevice-id}/users IMicrosoftGraphUser {}          {List}

   APIVersion: beta

Command                                 Module           Method URI                                                       OutputType           Permissions Variants
-------                                 ------           ------ ---                                                       ----------           ----------- --------
Get-MgDeviceManagementManagedDeviceUser DeviceManagement GET    /deviceManagement/managedDevices/{managedDevice-id}/users IMicrosoftGraphUser1 {}          {List1}

Please open a question/ticket at https://developer.microsoft.com/en-us/graph/support to get help from the API owner as this is an service related question.

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.