{"id":8872,"date":"2022-05-18T00:06:45","date_gmt":"2022-05-18T00:06:45","guid":{"rendered":"https:\/\/blogs.aaddevsup.xyz\/?p=8872"},"modified":"2022-05-18T19:17:10","modified_gmt":"2022-05-18T19:17:10","slug":"how-to-use-microsoft-graph-sdk-for-powershell-to-update-a-registered-devices-extension-attribute","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2022\/05\/how-to-use-microsoft-graph-sdk-for-powershell-to-update-a-registered-devices-extension-attribute\/","title":{"rendered":"How to use Microsoft Graph SDK for PowerShell to update a registered Device’s Extension Attribute"},"content":{"rendered":"\n

Below is a sample PowerShell script showing how to update a registered device’s extension attribute. The sample uses extensionAttriubte3. You can easily swap this out to a different one. Refer to the Update Device documentation<\/a> for more info.<\/p>\n\n\n\n

Import-Module Microsoft.Graph.Identity.DirectoryManagement\n# Log in with the correct scope\nConnect-MgGraph -Scopes \"Directory.AccessAsUser.All\"\n\n$DeviceId = \"<Device ObjectId>\"\n$params = @{\n   \"extensionAttributes\" = @{\n      \"extensionAttribute3\" = \"hello2\"\n   }\n}\n# Update Device\nUpdate-MgDevice  -DeviceId $DeviceId  -BodyParameter ($params | ConvertTo-Json)\n\n<# \nThe following technique to create json payload also works.  Thanks to my colleague Will Fiddes for the idea\n$json = '{ \"extensionAttributes\": { \"extensionAttribute1\": \"BYOD-Device\" } }'\nUpdate-MgDevice -DeviceId $DeviceId -BodyParameter $json\n#>\n\n# Query Device\nGet-MgDeviceById -DeviceId $DeviceId<\/pre>\n\n\n\n

Note: The above device update operation requires the signed in user to be in either the Intune Administrator role or Global Administrator role.<\/p>\n","protected":false},"excerpt":{"rendered":"

Below is a sample PowerShell script showing how to update a registered device’s extension attribute. The sample uses extensionAttriubte3. You can easily swap this out to a different one. Refer to the Update Device documentation for more info. Note: The above device update operation requires the signed in user to be in either the Intune Administrator role or Global Administrator role.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,11,225],"tags":[274],"class_list":["post-8872","post","type-post","status-publish","format-standard","hentry","category-authentication","category-azure-ad","category-ms-graph-client","category-powershell","tag-microsoft-graph-powershell"],"_links":{"self":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/8872"}],"collection":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/comments?post=8872"}],"version-history":[{"count":7,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/8872\/revisions"}],"predecessor-version":[{"id":8879,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/posts\/8872\/revisions\/8879"}],"wp:attachment":[{"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/media?parent=8872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/categories?post=8872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.aaddevsup.xyz\/wp-json\/wp\/v2\/tags?post=8872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}