Closed dapf27 closed 1 day ago
Probably there is, but I've not played with it. It would require additional logic, checking if folder exists, creating it and so on. Doable, but requires some work.
Would love that functionality as well, if it's in your plans.
I need to sit down to it and fix it. So ye, it's in plans.
This feature will be in new release. Ability to sync to a folder. The folder will be created before creating contacts. This release also allows to use filters.
Sync-O365PersonalContact -UserId 'przemyslaw.klys@test.pl' -MemberTypes 'Contact', 'Member' -GuidPrefix 'O365Synchronizer' -PassThru {
Sync-O365PersonalContactFilter -Type Include -Property 'CompanyName' -Value 'Evotec*','Ziomek*' -Operator 'like'
Sync-O365PersonalContactFilterGroup -Type Include -GroupID 'e7772951-4b0e-4f10-8f38-eae9b8f55962'
} -FolderName 'O365Sync' -WhatIf | Format-Table
Please keep in mind that if you are switching from non-folder sync you first need to remove old syncs, or you will get sort of duplicates.
I've also added ability to clear contacts from that folder, and clear & delete the folder itself.
Clear-O365PersonalContact -Identity 'przemyslaw.klys@test.pl' -GuidPrefix 'O365Synchronizer' -FolderName 'O365' -WhatIf
Clear-O365PersonalContact -Identity 'przemyslaw.klys@test.pl' -GuidPrefix 'O365Synchronizer' -FolderName 'O365Sync' -FolderRemove -WhatIf
Of course please make sure to use WhatIf, testing to rule out potential bugs.
Thanks for your work. But I think it destroyed some things. Work good:
Don't work:
did you remove the old contacts first before introducing folders?
Updating and deleting contacts is based on unique id, if you are using same ID and guidprefix there will be duplicates and it will try to update in the main folder
Yes before starting it was all clean. I had now, that the update worked and at next run it didn't work, some users were updated and some got a duplicate. Running two times this: Sync-O365PersonalContact -UserId '@' -MemberTypes 'Member' -GuidPrefix 'O365Synchronizer' -FolderName 'O365Sync' It shouldn't create duplicates. The Clear-O365PersonalContact deletes only 10 contacts per run. And if I use the -FolderRemove parameter it says: Failed to remove folder O365Sync from @ because: [ErrorCannotDeleteObject] : Object cannot be deleted.
I'll take a look
This should fix it. 1.0.1. I forgot using -All switch which I guess would cause duplicates if the order of gathered objects was not the same, and it would cause clear to clear 10 at a time when using folder.
Thanks for the update but I still get duplicates and with Clear-O365PersonalContact it deletes still only 10 contacts per run.
Which version are you using? Can you provide logs?
ModuleType Version PreRelease Name
---------- ------- ---------- ----
Script 1.0.2 O365Synchronizer
What logs do you need?
First run: Second run:
Clear with only 10:
first of all: Thank you for your great work !
I have the same issue when I work with Folders. First Sync (e.g. 300 contacts) works well. Second sync -> the script says the User have only 10 contacts and will process 300 contacts. So I have 290 duplicates.
But all work fine without separate Folders (standard contact folder)
I use the lastest Version 1.0.2
The problem comes from:
Get-MgUserContactFolder -UserId $Identity -Filter "DisplayName eq '$FolderName'" -ExpandProperty Contacts -ErrorAction Stop -ALl
The ALL switch doesn't do anything. So I need to find proper way to do this.
This release should fix this issue:
Hi, I would like to use your nice module, but it would be nice to sync all that many contacts to a subfolder so it would be easier for the users to differentiate which are their own contacts and which are out of GAL. I saw in your code that the "ParentFolderId" is there, but would it be possible to use a param at the "Sync-O365PersonalContact" to create or update such a subfolder? Thank you!