microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
702 stars 168 forks source link

Remove-MgUserManagedDevice : No OData route exists that match template ~/entityset/key/navigation/key with http verb DELETE for request #1831

Closed Boston-of-Gilead closed 1 year ago

Boston-of-Gilead commented 1 year ago

Code I'm running:

Import-Module Microsoft.Graph.Authentication;
Import-Module Microsoft.Graph.DirectoryObjects;
Import-Module Microsoft.Graph.Devices.CorporateManagement;
Import-Module Microsoft.Graph.Groups;
Import-Module Microsoft.Graph.Identity.DirectoryManagement;
Import-Module Microsoft.Graph.Mail;
Import-Module Microsoft.Graph.Users;

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

Select-MgProfile -Name "beta";

Connect-MgGraph -Scopes "User.ReadWrite.All","Directory.ReadWrite.All","MailboxSettings.ReadWrite","Group.ReadWrite.All","Directory.AccessAsUser.All","DeviceManagementManagedDevices.ReadWrite.All"

$devs = Get-MgUserManagedDevice -userid $onlineAccount.Id -All:$true | ? { $_.OperatingSystem -ne "Windows" -and $_.OperatingSystem -ne "MacOs" -and $_.ComplianceState -ne "Compliant" } 

$devs | % {
    Echo $_.id
    Remove-MgUserManagedDevice -ManagedDeviceId $_.Id -UserId $onlineAccount.Id 
}

$devs produces the Id that I want: image

When I run the above code with -whatif:

image

When I run the code without -whatif:

image

Text of error:

Remove-MgUserManagedDevice : No OData route exists that match template ~/entityset/key/navigation/key with http verb DELETE for request 
/DeviceFE/StatelessDeviceFEService/users('<user id>')/managedDevices('<$dev.id>').
At C:\Users\<name>\Desktop\Get-MgDevices.ps1:30 char:5
+     Remove-MgUserManagedDevice -ManagedDeviceId $_.Id -UserId $online ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ UserId = <uid>, IfMatch =  }:<>f__AnonymousType185`3) [Remove-MgUserManagedDevice_Delete], RestException`1
    + FullyQualifiedErrorId : No method match route template,Microsoft.Graph.PowerShell.Cmdlets.RemoveMgUserManagedDevice_Delete

I tried this in Graph Explorer and confirmed that "DeviceManagementManagedDevices.ReadWrite.All" is the correct permission, it ran without issue over there. The url used: https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{<same id in $devs above>}

PS C:\Windows\system32> $PSVersionTable

Name                           Value                                                                                                                                     
----                           -----                                                                                                                                     
PSVersion                      5.1.17763.3770                                                                                                                            
PSEdition                      Desktop                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                   
BuildVersion                   10.0.17763.3770                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                           
WSManStackVersion              3.0                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                       
SerializationVersion           1.1.0.1         

PS C:\Windows\system32> get-module -ListAvailable

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands                                                                                               
---------- -------    ----                                ----------------                                                                                               
Binary     2.0.2.135  AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplicationExtensionProperty, Get-AzureADAp...
Script     3.1.0      ExchangeOnlineManagement            {Get-ConnectionInformation, Get-EXOCasMailbox, Get-EXOMailbox, Get-EXOMailboxFolderPermission...}              
Script     7.1.2      ImportExcel                         {Add-ConditionalFormatting, Add-ExcelChart, Add-ExcelDataValidationRule, Add-ExcelName...}                     
Manifest   1.6.0      Microsoft.Graph                                                                                                                                    
Script     1.6.0      Microsoft.Graph.Applications        {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgServicePrincipalKey, Add-MgServicePrincipalPassword...}
Script     1.6.0      Microsoft.Graph.Authentication      {Connect-MgGraph, Disconnect-MgGraph, Get-MgContext, Get-MgProfile...}                                         
Script     1.6.0      Microsoft.Graph.Bookings            {Get-MgBookingBusiness, Get-MgBookingBusinessAppointment, Get-MgBookingBusinessCalendarView, Get-MgBookingBu...
Script     1.6.0      Microsoft.Graph.Calendar            {Get-MgGroupCalendar, Get-MgGroupCalendarMultiValueExtendedProperty, Get-MgGroupCalendarPermission, Get-MgGr...
Script     1.6.0      Microsoft.Graph.ChangeNotifications {Get-MgSubscription, New-MgSubscription, Remove-MgSubscription, Update-MgSubscription}                         
Script     1.6.0      Microsoft.Graph.CloudCommunications {Clear-MgCommunicationPresence, Get-MgCommunicationCall, Get-MgCommunicationCallAudioRoutingGroup, Get-MgCom...
Script     1.6.0      Microsoft.Graph.Compliance          {Add-MgComplianceEdiscoveryCaseReviewSetQueryTag, Add-MgComplianceEdiscoveryCaseReviewSetToReviewSet, Close-...
Script     1.6.0      Microsoft.Graph.CrossDeviceExper... {Get-MgUserActivity, Get-MgUserActivityHistoryItem, Get-MgUserActivityHistoryItemActivity, Get-MgUserActivit...
Script     1.6.0      Microsoft.Graph.DeviceManagement    {Get-MgDeviceManagement, Get-MgDeviceManagementAdvancedThreatProtectionOnboardingStateSummary, Get-MgDeviceM...
Script     1.6.0      Microsoft.Graph.DeviceManagement... {Add-MgDeviceManagementGroupPolicyUploadedDefinitionFileLanguageFile, Approve-MgDeviceManagementAndroidManag...
Script     1.6.0      Microsoft.Graph.DeviceManagement... {Get-MgDeviceManagementApplePushNotificationCertificate, Get-MgDeviceManagementAuditEvent, Get-MgDeviceManag...
Script     1.6.0      Microsoft.Graph.DeviceManagement... {Get-MgDeviceManagementAndroid, Get-MgDeviceManagementAndroidDeviceOwnerEnrollmentProfile, Get-MgDeviceManag...
Script     1.6.0      Microsoft.Graph.DeviceManagement... {Compare-MgDeviceManagementIntent, Compare-MgDeviceManagementTemplate, Compare-MgDeviceManagementTemplateMig...
Script     1.6.0      Microsoft.Graph.Devices.CloudPrint  {Get-MgPrint, Get-MgPrintConnector, Get-MgPrintOperation, Get-MgPrintPrinter...}                               
Script     1.6.0      Microsoft.Graph.Devices.Corporat... {Clear-MgDeviceAppMgtWindowInformationProtectionDeviceRegistration, Get-MgDeviceAppMgt, Get-MgDeviceAppMgtAn...
Script     1.6.0      Microsoft.Graph.DirectoryObjects    {Confirm-MgDirectoryObjectMemberGroup, Confirm-MgDirectoryObjectMemberObject, Get-MgDirectoryObject, Get-MgD...
Script     1.6.0      Microsoft.Graph.Education           {Get-MgEducationClass, Get-MgEducationClassAssignment, Get-MgEducationClassAssignmentCategory, Get-MgEducati...
Script     1.6.0      Microsoft.Graph.Files               {Add-MgDriveListContentTypeBaseTypeCopy, Add-MgDriveListContentTypeCopy, Add-MgShareListContentTypeBaseTypeC...
Script     1.6.0      Microsoft.Graph.Financials          {Get-MgFinancial, Get-MgFinancialCompany, Get-MgFinancialCompanyAccount, Get-MgFinancialCompanyAgedAccountPa...
Script     1.6.0      Microsoft.Graph.Groups              {Add-MgGroupFavorite, Add-MgGroupToLifecyclePolicy, Confirm-MgGroupGrantedPermission, Confirm-MgGroupMemberG...
Script     1.6.0      Microsoft.Graph.Identity.Directo... {Confirm-MgAdministrativeUnitMemberGroup, Confirm-MgAdministrativeUnitMemberObject, Confirm-MgContactMemberG...
Script     1.6.0      Microsoft.Graph.Identity.Governance {Add-MgAccessReviewDecision, Get-MgAccessReview, Get-MgAccessReviewDecision, Get-MgAccessReviewInstance...}    
Script     1.6.0      Microsoft.Graph.Identity.SignIns    {Confirm-MgRiskyUserCompromised, Get-MgDataPolicyOperation, Get-MgIdentityConditionalAccessAuthenticationCon...
Binary     6.1907.1.0 Microsoft.Graph.Intune              {Set-MSGraphAlias, Get-MSGraphDebugInfo, Get-MSGraphAllPages}                                                  
Script     1.6.0      Microsoft.Graph.Mail                {Get-MgUserInferenceClassification, Get-MgUserInferenceClassificationOverride, Get-MgUserMailFolder, Get-MgU...
Script     1.6.0      Microsoft.Graph.Notes               {Get-MgGroupOnenoteNotebook, Get-MgGroupOnenoteNotebookSection, Get-MgGroupOnenoteNotebookSectionGroup, Get-...
Script     1.6.0      Microsoft.Graph.People              {Get-MgUserActivityStatistics, Get-MgUserLastSharedMethodInsight, Get-MgUserPerson, Get-MgUserProfile...}      
Script     1.6.0      Microsoft.Graph.PersonalContacts    {Get-MgUserContact, Get-MgUserContactExtension, Get-MgUserContactFolder, Get-MgUserContactFolderChildFolder...}
Script     1.6.0      Microsoft.Graph.Planner             {Get-MgGroupPlanner, Get-MgGroupPlannerPlan, Get-MgGroupPlannerPlanBucket, Get-MgGroupPlannerPlanBucketTask...}
Script     1.6.0      Microsoft.Graph.Reports             {Get-MgAuditLogDirectoryAudit, Get-MgAuditLogDirectoryProvisioning, Get-MgAuditLogProvisioning, Get-MgAuditL...
Script     1.6.0      Microsoft.Graph.SchemaExtensions    {Get-MgSchemaExtension, New-MgSchemaExtension, Remove-MgSchemaExtension, Update-MgSchemaExtension}             
Script     1.6.0      Microsoft.Graph.Search              {Get-MgExternal, Get-MgExternalConnection, Get-MgSearchEntity, Invoke-MgQuerySearch...}                        
Script     1.6.0      Microsoft.Graph.Security            {Get-MgSecurityAction, Get-MgSecurityAlert, Get-MgSecurityCloudAppSecurityProfile, Get-MgSecurityDomainSecur...
Script     1.6.0      Microsoft.Graph.Sites               {Add-MgSiteContentTypeBaseTypeCopy, Add-MgSiteContentTypeCopy, Add-MgSiteListContentTypeBaseTypeCopy, Add-Mg...
Script     1.6.0      Microsoft.Graph.Teams               {Add-MgChatMember, Add-MgTeamChannelMember, Add-MgTeamMember, Add-MgTeamPrimaryChannelMember...}               
Script     1.6.0      Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCreatedObject, Get-MgUserCreatedObjectByRef, Get-MgUserDirectReport...}                 
Script     1.6.0      Microsoft.Graph.Users.Actions       {Add-MgUserInsightSharedLastSharedMethodMicrosoftGraphWorkbookRange, Add-MgUserInsightSharedLastSharedMethod...
Script     1.6.0      Microsoft.Graph.Users.Functions     {Export-MgUserDeviceAndAppManagementData623C, Export-MgUserDeviceAndAppManagementDataD390, Find-MgUserRoomAc...
Script     1.6.0      Microsoft.Graph.WindowsUpdates      {Add-MgWindowsUpdatesDeploymentAudienceMember, Add-MgWindowsUpdatesDeploymentAudienceMemberById, Add-MgWindo...
Script     1.0.1      Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}                                                          
Script     1.4.7      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                                         
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                                         
Script     3.4.0      Pester                              {Describe, Context, It, Should...}                                                                             
Manifest   3.0.0      Posh-SSH                            {Get-SCPItem, Get-SFTPItem, New-SFTPSession, New-SSHSession...}                                                
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}                                          
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                                   
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLineOption...}     

    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                ExportedCommands                                                                                               
---------- -------    ----                                ----------------                                                                                               
Manifest   1.0.1.0    ActiveDirectory                     {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPol...
Manifest   1.0.0.0    AppBackgroundTask                   {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroundTaskResourc...
Manifest   2.0.0.0    AppLocker                           {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}               
Manifest   1.0.0.0    AppvClient                          {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}              
Manifest   2.0.1.0    Appx                                {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}                             
Manifest   1.0        BestPractices                       {Get-BpaModel, Get-BpaResult, Invoke-BpaModel, Set-BpaResult}                                                  
Manifest   2.0.0.0    BitsTransfer                        {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTransfer...}                                
Manifest   1.0.0.0    BranchCache                         {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading...}                                
Manifest   1.0.0.0    CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}                                  
Manifest   1.0        ConfigCI                            {Get-SystemDriver, New-CIPolicyRule, New-CIPolicy, Get-CIPolicy...}                                            
Manifest   1.0        ConfigDefender                      {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference...}                                 
Manifest   1.0.1.0    DeliveryOptimization                {Get-DeliveryOptimizationStatus, Get-DeliveryOptimizationPerfSnap, Get-DeliveryOptimizationLog, Get-DOConfig...
Binary     2.0.0.0    DFSR                                {New-DfsReplicationGroup, Get-DfsReplicationGroup, Set-DfsReplicationGroup, Remove-DfsReplicationGroup...}     
Manifest   1.0.0.0    DirectAccessClientComponents        {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, Get-DAClientExperienceConfiguratio...
Script     3.0        Dism                                {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsCapability, Add-WindowsImage...}                    
Manifest   1.0.0.0    DnsClient                           {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache...}                                  
Manifest   1.0.0.0    EventTracingManagement              {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSession, Update-EtwTraceSession...}                   
Script     3.1.0      ExchangeOnlineManagement            {Get-ConnectionInformation, Get-EXOCasMailbox, Get-EXOMailbox, Get-EXOMailboxFolderPermission...}              
Manifest   1.0.0.0    GroupPolicy                         {Backup-GPO, Block-GPInheritance, Copy-GPO, Get-GPInheritance...}                                              
Binary     2.0.0.0    Hyper-V                             {Add-VMAssignableDevice, Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMGpuPartitionAdapter...}                  
Binary     1.1        Hyper-V                             {Add-VMDvdDrive, Add-VMFibreChannelHba, Add-VMHardDiskDrive, Add-VMMigrationNetwork...}                        
Script     1.1.0.0    IISAdministration                   {Get-IISAppPool, Start-IISCommitDelay, Stop-IISCommitDelay, Get-IISSite...}                                    
Manifest   2.0.0.0    International                       {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMethodOverride, Get-WinHomeLocation, Set-WinHomeLocat...
Manifest   1.0.0.0    iSCSI                               {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPortal, Update-IscsiTargetPortal...}          
Manifest   2.0.0.0    IscsiTarget                         {Add-ClusteriSCSITargetServerRole, Add-IscsiVirtualDiskTargetMapping, Checkpoint-IscsiVirtualDisk, Convert-I...
Script     1.0.0.0    ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}                                                            
Manifest   1.0.0.0    Kds                                 {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguration...}                                     
Manifest   1.0.1.0    Microsoft.PowerShell.Archive        {Compress-Archive, Expand-Archive}                                                                             
Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}                                                 
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}                                                                            
Manifest   1.0.0.0    Microsoft.PowerShell.LocalAccounts  {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup...}                                 
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}                                                 
Script     1.0        Microsoft.PowerShell.ODataUtils     Export-ODataEndpointProxy                                                                                      
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}                                                      
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}                                                     
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}                         
Manifest   1.0        MMAgent                             {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}                                                 
Manifest   1.0.0.0    MsDtc                               {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Join-DtcDiagnosticResourceManager, Receive...
Manifest   2.0.0.0    NetAdapter                          {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, Disable-NetAdapterEncapsu...
Manifest   1.0.0.0    NetConnection                       {Get-NetConnectionProfile, Set-NetConnectionProfile}                                                           
Manifest   1.0.0.0    NetDiagnostics                      Get-NetView                                                                                                    
Manifest   1.0.0.0    NetEventPacketCapture               {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetEventSession...}                     
Manifest   2.0.0.0    NetLbfo                             {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTeamMember...}                         
Manifest   1.0.0.0    NetNat                              {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNatSession...}                         
Manifest   2.0.0.0    NetQos                              {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}                                    
Manifest   2.0.0.0    NetSecurity                         {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoProposal, New-NetIPsecQuickModeCryp...
Manifest   1.0.0.0    NetSwitchTeam                       {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwitchTeam...}                          
Manifest   1.0.0.0    NetTCPIP                            {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Protocol...}                            
Manifest   1.0.0.0    NetWNV                              {Get-NetVirtualizationProviderAddress, Get-NetVirtualizationGlobal, Get-NetVirtualizationLookupRecord, Get-N...
Manifest   1.0.0.0    NetworkConnectivityStatus           {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfiguration, Set-NCSIPolicyConfigura...
Manifest   1.0.0.0    NetworkSwitchManager                {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchEthernetPort, Remove-...
Manifest   1.0.0.0    NetworkTransition                   {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-NetIPHttpsProfile, Disable-NetNat...
Manifest   1.0        NFS                                 {Get-NfsMappedIdentity, Get-NfsNetgroup, Install-NfsMappingStore, New-NfsMappedIdentity...}                    
Manifest   1.0.0.0    PcsvDevice                          {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice...}                                     
Binary     1.0.0.0    PersistentMemory                    {Get-PmemDisk, Get-PmemPhysicalDevice, Get-PmemUnusedRegion, New-PmemDisk...}                                  
Manifest   1.0.0.0    PKI                                 {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-PfxCertificate, Get-CertificateAutoEnroll...
Manifest   1.0.0.0    PlatformIdentifier                  Get-PlatformIdentifier                                                                                         
Manifest   1.0.0.0    PnpDevice                           {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}                                    
Manifest   1.1        PrintManagement                     {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfiguration...}                                   
Binary     1.0.11     ProcessMitigations                  {Get-ProcessMitigation, Set-ProcessMitigation, ConvertTo-ProcessMitigationPolicy}                              
Manifest   1.1        PSDesiredStateConfiguration         {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publish-DscConfiguration...} 
Script     1.0.0.0    PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}                         
Binary     1.1.0.0    PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}                                         
Manifest   2.0.0.0    PSWorkflow                          {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}                                                   
Manifest   1.0.0.0    PSWorkflowUtility                   Invoke-AsWorkflow                                                                                              
Manifest   2.0.0.0    RemoteDesktop                       {Get-RDCertificate, Set-RDCertificate, New-RDCertificate, New-RDVirtualDesktopDeployment...}                   
Manifest   2.0.0.0    RemoteDesktopServices               Convert-License                                                                                                
Manifest   1.0.0.0    ScheduledTasks                      {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-ScheduledTask...}                    
Manifest   2.0.0.0    SecureBoot                          {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-SecureBootUEFI...}                     
Manifest   1.0.0.0    SecurityCmdlets                     {Backup-SecurityPolicy, Restore-SecurityPolicy, Backup-AuditPolicy, Restore-AuditPolicy}                       
Script     1.0.0.0    ServerCore                          {Get-DisplayResolution, Set-DisplayResolution}                                                                 
Script     2.0.0.0    ServerManager                       {Get-WindowsFeature, Install-WindowsFeature, Uninstall-WindowsFeature, Enable-ServerManagerStandardUserRemot...
Cim        1.0.0.0    ServerManagerTasks                  {Get-SMCounterSample, Get-SMPerformanceCollector, Start-SMPerformanceCollector, Stop-SMPerformanceCollector...}
Manifest   2.0.0.0    SmbShare                            {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}                                         
Manifest   2.0.0.0    SmbWitness                          {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}                                                 
Manifest   2.0.0.0    SoftwareInventoryLogging            {Get-SilComputer, Get-SilComputerIdentity, Get-SilSoftware, Get-SilWindowsUpdate...}                           
Manifest   1.0.0.0    StartLayout                         {Export-StartLayout, Import-StartLayout, Export-StartLayoutEdgeAssets, Get-StartApps}                          
Manifest   2.0.0.0    Storage                             {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-StorageFaultDomain...}            
Manifest   1.0.0.0    StorageBusCache                     {Clear-StorageBusDisk, Disable-StorageBusCache, Disable-StorageBusDisk, Enable-StorageBusCache...}             
Manifest   2.0.0.0    TLS                                 {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disable-TlsSessionTicketKey, Export-TlsSessionTicketKe...
Manifest   1.0.0.0    TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}                                                          
Manifest   2.0.0.0    TrustedPlatformModule               {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}                                                           
Binary     2.1.639.0  UEV                                 {Clear-UevConfiguration, Clear-UevAppxPackage, Restore-UevBackup, Set-UevTemplateProfile...}                   
Manifest   2.0.0.0    UpdateServices                      {Add-WsusComputer, Approve-WsusUpdate, Deny-WsusUpdate, Get-WsusClassification...}                             
Manifest   1.0.0.0    UserAccessLogging                   {Enable-Ual, Disable-Ual, Get-Ual, Get-UalDns...}                                                              
Manifest   2.0.0.0    VpnClient                           {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnection...}                             
Manifest   1.0.0.0    Wdac                                {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}                                                  
Manifest   1.0.0.0    WebAdministration                   {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock, Remove-WebConfigurationLock...}          
Manifest   2.0.0.0    Whea                                {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}                                                                   
Manifest   1.0.0.0    WindowsDeveloperLicense             {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-WindowsDeveloperLicenseRegistration}    
Script     1.0        WindowsErrorReporting               {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsErrorReporting}                       
Manifest   1.0.0.0    WindowsSearch                       {Get-WindowsSearchSetting, Set-WindowsSearchSetting}                                                           
Manifest   1.0.0.0    WindowsUpdate                       Get-WindowsUpdateLog                                                                                           
Manifest   1.0.0.2    WindowsUpdateProvider               {Get-WUAVersion, Get-WULastInstallationDate, Get-WULastScanSuccessDate, Get-WUIsPendingReboot...}              

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands                                                                                               
---------- -------    ----                                ----------------                                                                                               
Binary     6.1907.1.0 Microsoft.Graph.Intune              {Set-MSGraphAlias, Get-MSGraphDebugInfo, Get-MSGraphAllPages}                                                  
peombwa commented 1 year ago

@Boston-of-Gilead, according to Find-MGgraphCommand, the command to use is Remove-MgDeviceManagementManagedDevice:

➜ Find-MGgraphCommand -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{id}"

   APIVersion: v1.0

Command                                Module           Method URI                                                 OutputType
-------                                ------           ------ ---                                                 ----------
Get-MgDeviceManagementManagedDevice    DeviceManagement GET    /deviceManagement/managedDevices/{managedDevice-id} IMicrosoftGraphManage…
Remove-MgDeviceManagementManagedDevice DeviceManagement DELETE /deviceManagement/managedDevices/{managedDevice-id}
Update-MgDeviceManagementManagedDevice DeviceManagement PATCH  /deviceManagement/managedDevices/{managedDevice-id} IMicrosoftGraphManage…

This corresponds to the API you used in Graph Explorer - https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{<same id in $devs above>}.

Remove-MgUserManagedDevice, which calls DELETE /users/{user-id}/managedDevices/{managedDevice-id}, is currently listed as supported in the service schema. However, as shown in the error message (-Debug), the service currently returns No OData route exists that match template ~/entityset/key/navigation/key with http verb DELETE for request when calling the API.

I'll transfer the issue to the service metadata for this to be fixed by the API owner.

Please use Remove-MgDeviceManagementManagedDevice instead.

peombwa commented 1 year ago

Issue has been transferred to https://github.com/microsoftgraph/msgraph-metadata/issues/287.

Boston-of-Gilead commented 1 year ago

@Boston-of-Gilead, according to Find-MGgraphCommand, the command to use is Remove-MgDeviceManagementManagedDevice:

➜ Find-MGgraphCommand -Uri "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{id}"

   APIVersion: v1.0

Command                                Module           Method URI                                                 OutputType
-------                                ------           ------ ---                                                 ----------
Get-MgDeviceManagementManagedDevice    DeviceManagement GET    /deviceManagement/managedDevices/{managedDevice-id} IMicrosoftGraphManage…
Remove-MgDeviceManagementManagedDevice DeviceManagement DELETE /deviceManagement/managedDevices/{managedDevice-id}
Update-MgDeviceManagementManagedDevice DeviceManagement PATCH  /deviceManagement/managedDevices/{managedDevice-id} IMicrosoftGraphManage…

This corresponds to the API you used in Graph Explorer - https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{<same id in $devs above>}.

Remove-MgUserManagedDevice, which calls DELETE /users/{user-id}/managedDevices/{managedDevice-id}, is currently listed as supported in the service schema. However, as shown in the error message (-Debug), the service currently returns No OData route exists that match template ~/entityset/key/navigation/key with http verb DELETE for request when calling the API.

I'll transfer the issue to the service metadata for this to be fixed by the API owner.

Please use Remove-MgDeviceManagementManagedDevice instead.

That works, thanks so much!