mirror of
https://github.com/fleetdm/fleet
synced 2026-05-22 00:18:27 +00:00
Changes: - Windows MDM setup guide update: include instructions how to turn off MDM - Redirect: new link `learn-more-about/windows-mdm` that will be used in the error message.
29 lines
832 B
PowerShell
29 lines
832 B
PowerShell
# Please don't delete. This script is referenced in the guide here: https://fleetdm.com/guides/windows-mdm-setup#turn-off-windows-mdm
|
|
|
|
Add-Type -TypeDefinition @"
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public class MdmRegistration
|
|
{
|
|
[DllImport("mdmregistration.dll", SetLastError = true)]
|
|
public static extern int UnregisterDeviceWithManagement(IntPtr pDeviceID);
|
|
|
|
public static int UnregisterDevice()
|
|
{
|
|
return UnregisterDeviceWithManagement(IntPtr.Zero);
|
|
}
|
|
}
|
|
"@ -Language CSharp
|
|
|
|
try {
|
|
$result = [MdmRegistration]::UnregisterDevice()
|
|
|
|
if ($result -ne 0) {
|
|
throw "UnregisterDeviceWithManagement failed with error code: $result"
|
|
}
|
|
|
|
Write-Host "Device unregistration called successfully."
|
|
} catch {
|
|
Write-Error "Error calling UnregisterDeviceWithManagement: $_"
|
|
}
|