Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in offboarding operation: Please ensure device names are valid #12

Open
amagre opened this issue Jul 25, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@amagre
Copy link

amagre commented Jul 25, 2024

I keep getting this error when checking the log file on a number of devices when offboarding even though I have checked those devices exist in Entra ID and Intune:
"Error in offboarding operation. Exception: Cannot process argument transformation on parameter 'DeviceId'. Cannot convert value to type System.String."

Screenshot 2024-07-25 110356

I have also checked the device name and there is nothing unusual in the name. Any ideas or has anyone else seen this issue?

Thanks

@amagre
Copy link
Author

amagre commented Jul 25, 2024

Also noticed this script cannot handle duplicate entries found in Entra ID, which isn't great if you have to then go in manually to delete from Entra ID.
Screenshot 2024-07-25 111933

@ugurkocde ugurkocde self-assigned this Jul 26, 2024
@ugurkocde ugurkocde added the bug Something isn't working label Jul 26, 2024
@blinkblinktwo
Copy link

Nifty project, thanks.

I tried some cases where there were only some "objects" available between AP, Intune, and AAD, and not all three.
This also seemed to cause some problems for searching devices and serials.

I was also looking at adding individual "offboard" buttons for each area to test finding/removing individual objects.


$OffboardButton2.Add_Click({

    if ($AuthenticateButton.IsEnabled) {
        Write-Log "User is not connected to MS Graph. Attempted offboarding operation."
        [System.Windows.MessageBox]::Show("You are not connected to MS Graph. Please connect first.")
        return
    }

    $confirmationResult = [System.Windows.MessageBox]::Show("Are you sure you want to proceed with INTUNE offboarding? This action cannot be undone.", "Confirm Offboarding", [System.Windows.MessageBoxButton]::YesNo)
    if ($confirmationResult -eq 'No') {
        Write-Log "User canceled offboarding operation."
        return
    }

    try {
        $SearchTexts = $SearchInputText.Text -split ', '

        foreach ($SearchText in $SearchTexts) {
            if (![string]::IsNullOrEmpty($SearchText)) {
                $IntuneDevice = Get-MgDeviceManagementManagedDevice -Filter "deviceName eq '$SearchText'" -ErrorAction Stop


                if ($IntuneDevice) {
                    Remove-MgDeviceManagementManagedDevice -ManagedDeviceId $IntuneDevice.Id -PassThru -ErrorAction Stop
                    [System.Windows.MessageBox]::Show("Successfully removed device $SearchText from INTUNE.")
                    $Window.FindName('intune_status').Text = "Intune: Unavailable"
                    Write-Log "Successfully removed device $SearchText from INTUNE."
                }
                else {
                    [System.Windows.MessageBox]::Show("Device $SearchText not found in INTUNE.")
                }


            }
            else {
                [System.Windows.MessageBox]::Show("Please provide a valid INTUNE device name.")
            }
        }
    }
    catch {
        Write-Log "Error in INTUNE offboarding operation. Exception: $_"
        [System.Windows.MessageBox]::Show("Error in INTUNE offboarding operation. Please ensure device names are valid.")
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants