Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cosminonea/d433324d05f6d60c91387b1e6853a166 to your computer and use it in GitHub Desktop.
Save cosminonea/d433324d05f6d60c91387b1e6853a166 to your computer and use it in GitHub Desktop.
param(
$relyingPartyUrl,
$ruleFilePath
)
Import-Module ADFS
$party = Get-ADFSRelyingPartyTrust -Name "$relyingPartyUrl"
if($party)
{
Write-Host "Removing Relying Party $relyingPartyUrl"
$party | Remove-ADFSRelyingPartyTrust
}
Write-Host "Creating relying party $relyingPartyUrl"
Add-ADFSRelyingPartyTrust -Name "$relyingPartyUrl" `
-Identifier "$relyingPartyUrl" `
-WSFedEndpoint "$relyingPartyUrl" `
-IssuanceAuthorizationRules "@RuleTemplate=`"AllowAllAuthzRule`" => issue(Type = `"http://schemas.microsoft.com/authorization/claims/permit`", Value=`"true`");"
$party = Get-ADFSRelyingPartyTrust -Name "$relyingPartyUrl"
Write-Host "Adding Claim Transform Rules"
$ruleFilePath = Resolve-Path $ruleFilePath
$rulesString = [System.IO.File]::ReadAllText($ruleFilePath)
Write-Host $rulesString
$party | Set-ADFSRelyingPartyTrust -IssuanceTransformRules $rulesString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment