14 July 2022

Update-Module - Module PowershellGet was not installed by using Install-Module, so it cannot be updated.

Well there we go again, something that should be easy and take 5 minutes turns in to a 3 hour job.

How we got here?

Install-Module : A parameter cannot be found that matches parameter name ‘AllowPrerelease’

Okay, so if that doesn't work, then try to update it.
No bueno, this is because PowerShellGet comes builtin with Windows 2016 but it's on older version. If you want all bells and whistles you need to install newest version from PowerShellGallery.

That doesn't really help.
But what does help is going full mental.
PowerShellGet 1.0.0.1 does not update properly.

Now try the aggressive way of  forcing your will onto this module.

Browse to C:\Program Files\WindowsPowerShell\Modules\
Open the folder C:\Program Files\WindowsPowerShell\Modules\PowershellGet and delete the subfolder 1.0.0.1
Open the folder C:\Program Files\WindowsPowerShell\Modules\PackageManagement and delete the subfolder 1.0.0.1
Browse to C:\Program Files (x86)\WindowsPowerShell\Modules\
Open the folder C:\Program Files (x86)\WindowsPowerShell\Modules\PowershellGet and delete the subfolder 1.0.0.1
Open the folder C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement and delete the subfolder 1.0.0.1

Now run Install-Module PowerShellGet -Force and Update-Module PowerShellGet

Check for correct installation and mudule version with Get-Command Install-Module.

Stopped deletion threshold exceeded - Azure AD Connect

After deleting a lot of old AD groups the Azure AD Connect sync stopped working.
We could start the sync no problem, but nothing was being synced.

In the Synchronization Service Manager we could see the following error:
stopped-deletion-threshold-exceeded

Turns out there is a limit of 500 items that get synced at once. Go over this and every thing stops. I had no idea this was in place, but its on by default. So in case of an accidental deletion your stuff gets saved , yay!

I came across this blogpost that explains just this problem, so Ali Tajran over at https://www.alitajran.com saved a couple of hours of trouble shooting and I learned something new đŸ˜„

First run PowerShell as administrator. Run the Get-ADSyncExportDeletionThreshold cmdlet to check both the objects DeletionPrevention and TresholdCount.
- DeletionPrevention is 1 (enable)
- ThresholdCount is 500 (default AD objects)



The solution for stopped-deletion-threshold-exceeded is to disable the export deletion threshold with PowerShell.

Step 1: Disable Azure AD Connect sync export deletion threshold with the Disable-ADSyncExportDeletionThreshold cmdlet.
PS C:\> Disable-ADSyncExportDeletionThreshold

DeletionPrevention ThresholdPercentage ThresholdCount
------------------ ------------------- --------------
                 0                   0            500
Step 2: Force sync Azure AD Connect

Force sync Azure AD Connect with PowerShell. The initial sync will do a full sync from AD on-premises to Azure AD. You can also run a Policytype Delta sync to only sync the changes, this is faster.
PS C:\> Start-ADSyncSyncCycle -PolicyType Initial
Step 3: Verify Synchronization Service status

In Synchronization Service Manager, check that the export status shows as success. In our example, the export did delete 5069 AD objects.
Stopped deletion threshold exceeded - Azure AD Connect after
Step 4: Enable Azure AD Connect sync export deletion threshold

Revert the change to protect AD objects from accidental removal. The default is 500 AD objects.
PS C:\> Enable-ADSyncExportDeletionThreshold -DeletionThreshold 500

DeletionPrevention ThresholdPercentage ThresholdCount
------------------ ------------------- --------------
                 1                   0            500

Source