Untitled
unknown
plain_text
a year ago
1.4 kB
2
Indexable
# Imposta le variabili per Outlook $Outlook = New-Object -ComObject Outlook.Application $Namespace = $Outlook.GetNamespace("MAPI") $PublicFolders = $Namespace.GetDefaultFolder(18) # 18 corrisponde alle cartelle pubbliche # Accedi alla cartella pubblica desiderata $ContactsFolder = $PublicFolders.Folders | Where-Object { $_.Name -eq "Rubrica Generale" } # Definisci la dimensione del batch $batchSize = 100 $duplicatesRemoved = $true # Continua a rimuovere i duplicati finché ce ne sono while ($duplicatesRemoved) { $Contacts = $ContactsFolder.Items $UniqueContacts = @{} $duplicatesRemoved = $false $batchCount = [math]::Ceiling($Contacts.Count / $batchSize) for ($i = 0; $i -lt $batchCount; $i++) { $start = $i * $batchSize $end = ($i + 1) * $batchSize - 1 if ($end -ge $Contacts.Count) { $end = $Contacts.Count - 1 } for ($j = $start; $j -le $end; $j++) { $Contact = $Contacts[$j] if (-not [string]::IsNullOrWhiteSpace($Contact.MobileTelephoneNumber)) { if (-not $UniqueContacts.ContainsKey($Contact.MobileTelephoneNumber)) { $UniqueContacts.Add($Contact.MobileTelephoneNumber, $Contact) } else { $Contact.Delete() $duplicatesRemoved = $true } } } } }
Editor is loading...
Leave a Comment