Last active
March 9, 2018 08:33
-
-
Save michaelkc/4219ea4a8bf240c8f55ecfd3e9e849f4 to your computer and use it in GitHub Desktop.
ADFS v2016 cmdlet hang repro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version Latest | |
$ErrorActionPreference = "Stop" | |
$VerbosePreference = "Continue" | |
# https://social.technet.microsoft.com/Forums/ie/en-US/8553bfcb-6170-4c25-8cb7-0f83e3bb0370/periodic-hangs-when-using-the-builtin-adfs-powershell-cmdlets-in-adfs-v2016?forum=ADFS | |
$iterations = 50 | |
$sw = [system.diagnostics.stopwatch]::startNew() | |
$rpNames = 1..50|ForEach-Object { "HangReproRP$_" } | |
Write-Verbose "Ensuring repro RPs are created..." | |
foreach ($rpName in $rpNames) | |
{ | |
$existingRp = Get-AdfsRelyingPartyTrust -Name $rpName | |
if (-not $existingRp) | |
{ | |
$identifier = "https://example.com/$rpName/" | |
$wsFedEndpoint = $identifier | |
Write-Verbose "RP $rpName does not exist, adding..." | |
Add-AdfsRelyingPartyTrust -Name $rpName -Identifier $identifier -WSFedEndpoint $wsFedEndpoint | |
} | |
else | |
{ | |
Write-Verbose "RP $rpName exists" | |
} | |
} | |
Write-Verbose "Repro RPs OK" | |
Write-Verbose "Querying all RP names..." | |
$iteration = 1 | |
while ($iteration -le $iterations) | |
{ | |
Write-Verbose "Iteration $iteration" | |
foreach ($rpName in $rpNames) | |
{ | |
Write-Verbose "Get-AdfsRelyingPartyTrust -Name $rpName" | |
$rp = Get-AdfsRelyingPartyTrust -Name $rpName | |
Write-Verbose "$($rp.Name) OK" | |
} | |
$iteration++ | |
} | |
Write-Verbose "Completed $iterations iterations" | |
$sw.Elapsed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment