Git Product home page Git Product logo

Comments (11)

johnathanhall avatar johnathanhall commented on May 23, 2024 1

I found a work around to do the same thing.
Instead of using Update-DeviceManagement_ManagedDevices -managedDeviceId $id -deviceCategory $category Or from the Preview Update-IntuneManagedDevice -managedDeviceId $id -deviceCategory $category
I used:

$DeviceID = "5d1ffe77-5767-45ef-8400-b7aa82e12591"
$DeviceCategory = '79891b7b-e26f-47ba-9e47-5a3dcf111e1d'
$uri = "https://graph.microsoft.com/beta/deviceManagement/managedDevices('$DeviceID')/deviceCategory/" + '$ref'
$JSON = @{ "@odata.id" = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$DeviceCategory" } | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Headers $authToken -Method Put -Body $JSON -ContentType "application/json"

Still not sure why Update-IntuneManagedDevice can't assign a category though.

from intune-powershell-sdk.

nsoy avatar nsoy commented on May 23, 2024 1

investigating..

from intune-powershell-sdk.

John-Matlock avatar John-Matlock commented on May 23, 2024

I'm having this same problem.

from intune-powershell-sdk.

timmyit avatar timmyit commented on May 23, 2024

In the documentation ManagedDevices un the Method "Update_DeviceManagement_ManagedDevices" it has System.Object deviceCategory as a parameter. As this is the only reference I could find that might be able to assign a Device category to a device.
I'm getting an error when trying to update this field for a device Using this command:
Update-DeviceManagement_ManagedDevices -managedDeviceId $id -deviceCategory $category
powershell category assign error

I also notice that deviceCategory wasn't specified in the Microsoft Graph REST API V1.0 or Beta documentation for Update managedDevice

Am I just missing something for the method call or it this a bug?

Thanks,

Johnathan

I see the same issue when trying to use Update-DeviceManagement_ManagedDevices when trying to update names on iOS devices. But using Invoke-Restmethod works fine so Its something wrong with the cmdlet.

from intune-powershell-sdk.

timmyit avatar timmyit commented on May 23, 2024

investigating..

Awesome, let us know if there's anything we can do to help.

from intune-powershell-sdk.

nsoy avatar nsoy commented on May 23, 2024

I confirm what @johnathanhall reported above. Since this route is not exposed in the v1.0 schema, the only way to set categories on IntuneManagedDevices is via direct Invoke-RestMethod to the beta route.
$uri = "https://graph.microsoft.com/**beta**/deviceManagement/managedDevices('$DeviceID')/deviceCategory/" + '$ref'
$JSON = @{ "@odata.id" = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$DeviceCategory" } | ConvertTo-Json
Invoke-RestMethod -Uri $uri -Headers $authToken -Method Put -Body $JSON -ContentType "application/json"

from intune-powershell-sdk.

mkalees1 avatar mkalees1 commented on May 23, 2024

Update-IntuneManagedDevice -managedDeviceId $deviceID -deviceCategoryDisplayName $Displayname

Am also getting the same error. Any fix on this

from intune-powershell-sdk.

rohitramu avatar rohitramu commented on May 23, 2024

You can change the schema used by the module to "beta" by running the following command:

Update-MSGraphEnvironment -SchemaVersion 'beta'

After this, you should only use the Invoke-MSGraphRequest cmdlet to make calls to Graph, since the standard (generated) cmdlets might not have the properties or entities you would like to use in the "beta" schema. Using the standard cmdlets (e.g. Update-IntuneManagedDevice or Update-DeviceManagement_ManagedDevices) might result in unexpected behavior. To achieve the same as @johnathanhall's example above, you can do the following:

# Get the device ID and device category ID to associate
$DeviceID = "5d1ffe77-5767-45ef-8400-b7aa82e12591"
$DeviceCategory = '79891b7b-e26f-47ba-9e47-5a3dcf111e1d'

# Create the request body which would associate the two objects
$requestBody = @{ "@odata.id" = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$DeviceCategory" }

# Make the call to Graph which will create the association
Invoke-MSGraphRequest -HttpMethod PUT -Url "deviceManagement/managedDevices/$DeviceID/deviceCategory/`$ref" -Content $requestBody

from intune-powershell-sdk.

cmcapellan avatar cmcapellan commented on May 23, 2024

Small typo...for
Invoke-MSGraphRequest -HttpMethod PUT -Url "deviceManagement/managedDevices/$DeviceID/deviceCategory/`$ref" -Body $requestBody
should be -Content, not -Body

from intune-powershell-sdk.

rohitramu avatar rohitramu commented on May 23, 2024

Oops, thanks for pointing that out @cmcapellan. I've fixed it now in the sample code.

from intune-powershell-sdk.

SamSepiolWarden avatar SamSepiolWarden commented on May 23, 2024

Still an issue on the cmdlet Update-MgDeviceManagementmanagedDevice or that was fixed ?

from intune-powershell-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.