< Back

Invoke-IntuneCleanup

Sat Jan 18, 2020 4:20 pm

NAME Invoke-IntuneCleanup



SYNOPSIS

This script performs a cleanup for duplicated device entries in Microsoft Intune based on the serial number.





SYNTAX

Invoke-IntuneCleanup [-WhatIf] [-Confirm] [<CommonParameters>]





DESCRIPTION

The script retrieves all devices from Intune and elaborates all duplicated devices based on the serial number.

Only the newest device (Last Synced) will stay in the environment.





PARAMETERS

-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Version: 1.0.0

Author: Thomas Kurth

Creation Date: 14.9.2019

Purpose/Change: Initial script development



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Invoke-IntuneCleanup -Whatif | Out-GridView -OutputMode Multiple | foreach-Object {

Remove-DeviceManagement_ManagedDevices -managedDeviceId $_.id }



Retrieves duplicate devices and displays them first in a Out-Gridview, to select the devices which should be

removed.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Invoke-IntuneCleanup



This command automatically removes duplicated objects based on the serial number.











RELATED LINKS

https://www.wpninjas.ch/2019/09/cleanup ... in-intune/