question

AndreasMhlemann-0578 avatar image
0 Votes"
AndreasMhlemann-0578 asked Crystal-MSFT commented

Add Groups to Intunes DeviceShell Script with powershell graph api not works - What is the correct commando?

Hello there
I have a problem with an Powershell Command from Module MicrosoftGraph.
Maybe is there anyone the can tell my what the correct command are.

The command

 Set-MgDeviceManagementDeviceConfiguration -DeviceConfigurationId $deviceConfigurationId -BodyParameter $params


With this body

 $params = @{
     Assignments = @(
         @{
             Target = @{
                 "@odata.type" = "#microsoft.graph.groupAssignmentTarget"
                 GroupId = <"GroupID">
             }
         }
     )
 }

It's working but remove all another assigned groups.

So I think the correct command will be the following:

 Update-MgDeviceManagementDeviceShellScript -DeviceShellScriptId $deviceShellScriptId -BodyParameter $params


But what is the correct Body and how do assign with more groups of times?

I have also tried with the following command:

 Update-MgDeviceManagementDeviceShellScript -DeviceShellScriptId "0cee72b4-6af0-4d25-96c1-ece01bd885f3" -GroupAssignments [TargetGroupId <GroupId>]


But I get a mistake back:

 Update-MgDeviceManagementDeviceShellScript: Cannot process argument transformation on parameter 'GroupAssignments'. Cannot convert value "[TargetGroupId" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphDeviceManagementScriptGroupAssignment[]". Error: "Cannot convert the "[TargetGroupId" value of type "System.String" to type “Microsoft.Graph.PowerShell.Models.IMicrosoftGraphDeviceManagementScriptGroupAssignment"."


Here link to Microsoft about this:
https://docs.microsoft.com/en-us/graph/api/intune-devices-deviceshellscript-update?view=graph-rest-beta.

I would be very happy if anyone could help me with my problem.





mem-intune-graph
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AndreasMhlemann-0578, Based on my test, I find the "Update-MgDeviceManagementDeviceShellScript" is not there after I import the module "Microsoft.Graph.DeviceManagement". But I find another command "Set-MgDeviceManagementDeviceShellScript" under "Microsoft.Graph.DeviceManagement.Actions".
https://docs.microsoft.com/en-us/powershell/module/microsoft.graph.devicemanagement.actions/set-mgdevicemanagementdeviceshellscript?view=graph-powershell-beta

For the example, of IMicrosoftGraphDeviceManagementScriptGroupAssignment[], after doing a lot of research, I didn't find one. To help you on this, I suggest to open a case to work on this. Here is link with the steps for the reference:
https://docs.microsoft.com/en-us/mem/get-support

@anyone, if anyone has used this before, I appreciate your help to share the information here.

Thanks for the understanding and have a nice day!

0 Votes 0 ·

0 Answers