Any option to enable lost mode in the Intune portal for the device using Graph API by Powershall script
Any option to enable lost mode in the Intune portal for the device using Graph API by Powershall script
@Babbab-7242, This is from Intune support. For your request, maybe you can try the following scripts:
import-Module Microsoft.Graph.Intune #import intune module
Update-MSGraphEnvironment -SchemaVersion beta #set schema version as beta
Connect-MSGraph #connect to MS grasp
$body = @{'message' = 'Please Contact me';
'phoneNumber' = '1111111111';
'footer'= 'Test'}
$bodyobj = New-Object -TypeName PSObject -Property $body
Invoke-MSGraphRequest -Url /deviceManagement/managedDevices/5cb***b603ea/enableLostMode -Content $bodyobj -HttpMethod POST
Note: Please change the related infromation as your reference.
Here is a link related with lost mode in Graph API for the referrence:
https://docs.microsoft.com/en-us/graph/api/intune-devices-manageddevice-enablelostmode?view=graph-rest-beta
Hope it can help.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Looks to be working. However, I am getting below error message. Any insights? Thanks!
Invoke-MSGraphRequest : 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'enableLostMode'.",
"innerError": {
"date": "2021-03-25T16:51:01",
"request-id": "988dc8bf-db90-47f9-83a9-6a9435330a81",
"client-request-id": "988dc8bf-db90-47f9-83a9-6a9435330a81"
}
}
}
At line:7 char:25
@Babbab-7242, Based as I know, the 'enableLostMode' can only be run on some specific devices. Could you go to Intune portal and check if the function is enabled on the device:?
https://docs.microsoft.com/en-us/mem/intune/remote-actions/device-lost-mode
I am able to enable/disable "Lost Mode" in the portal for the same device. However, if I run the Powershell command with Device ID, I am getting below error. Any insight for the "400 Bad Request" error? Thanks
Invoke-MSGraphRequest : 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'enableLostMode'.",
"innerError": {
"date": "2021-03-29T16:23:21",
"request-id": "da95d20f-a8f1-4d8e-b8d5-c8589aee12a2",
"client-request-id": "da95d20f-a8f1-4d8e-b8d5-c8589aee12a2"
}
}
}
At line:1 char:1
+ Invoke-MSGraphRequest -Url /deviceManagement/managedDevices/bdc8423b- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 people are following this question.
Manually policy sycnronisation of a "Hybrid Azure AD joined" device
Can Intune PowerShell return VPP enrolled devices (not yet assigned)?
How to distinguish devices non-compliancy reasons with Intune Data Warehouse in PowerBi
Intune and ADE - No VPP Tokens Found
How do I assign an iOS configuration profile to specific devices in Endpoint Manager