<# .SYNOPSIS Gives users (or a group) access to the Innovarro Signatures portal for your organisation. .DESCRIPTION Assigns the "Signatures.Admin" app role (or, with -Role, "Protection.Admin") of the Innovarro Signatures enterprise application in your Microsoft Entra ID. People with this role can sign in at https://signatures.innovarro.cloud and edit your organisation's signatures and user details. They cannot see other organisations. The enterprise application appears in your tenant after an administrator has connected it (admin consent, see the "Connect your Microsoft 365 tenant" guide). Requires the Microsoft Graph PowerShell SDK (Install-Module Microsoft.Graph.Applications, Microsoft.Graph.Users, Microsoft.Graph.Groups) and a Global Administrator, Privileged Role Administrator, Cloud Application Administrator or Application Administrator account. Assigning a group requires Entra ID P1 or higher. .PARAMETER User One or more user principal names (sign-in names). .PARAMETER Group Display name or object ID of a security group. .PARAMETER Role Signatures.Admin (default): every product of your organisation. Protection.Admin: Email & Domain Protection only (the Protection page). Use it for customers of Email & Domain Protection without Innovarro Signatures, and for people who should only see the DMARC and MTA-STS reports. .PARAMETER Remove Remove the role from the given users or group instead. .PARAMETER List Show who has access now. .EXAMPLE .\Grant-InnovarroSignaturesAdmin.ps1 -User anna@contoso.com,ben@contoso.com .\Grant-InnovarroSignaturesAdmin.ps1 -Group "Marketing signature editors" .\Grant-InnovarroSignaturesAdmin.ps1 -User it@contoso.com -Role Protection.Admin .\Grant-InnovarroSignaturesAdmin.ps1 -List .NOTES Innovarro Signatures - https://signatures.innovarro.cloud/support #> [CmdletBinding(SupportsShouldProcess)] param( [string[]]$User, [string]$Group, [switch]$Remove, [switch]$List, [ValidateSet('Signatures.Admin', 'Protection.Admin')] [string]$Role = 'Signatures.Admin', [string]$AppId = '4fe320b3-0e6c-4d6b-adb3-ff1ae591fa65' ) $ErrorActionPreference = 'Stop' $RoleValue = $Role if (-not (Get-Command Connect-MgGraph -ErrorAction SilentlyContinue)) { throw 'Microsoft Graph PowerShell is not installed. Run: Install-Module Microsoft.Graph.Applications, Microsoft.Graph.Users, Microsoft.Graph.Groups -Scope CurrentUser' } Connect-MgGraph -Scopes 'Application.Read.All', 'AppRoleAssignment.ReadWrite.All', 'User.Read.All', 'Group.Read.All' -NoWelcome $sp = Get-MgServicePrincipal -Filter "appId eq '$AppId'" if (-not $sp) { throw "Innovarro Signatures is not connected to this tenant yet. Follow the 'Connect your Microsoft 365 tenant' guide first: https://signatures.innovarro.cloud/support/connect-tenant" } $role = $sp.AppRoles | Where-Object Value -eq $RoleValue if (-not $role) { throw "App role $RoleValue not found on the application." } $assigned = Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $sp.Id -All | Where-Object AppRoleId -eq $role.Id if ($List -or (-not $User -and -not $Group)) { if ($assigned) { $assigned | Select-Object PrincipalDisplayName, PrincipalType, CreatedDateTime | Format-Table -AutoSize } else { Write-Host "Nobody has the $RoleValue role yet." -ForegroundColor Yellow } return } $principals = @() foreach ($u in $User) { $principals += Get-MgUser -UserId $u -Property Id, DisplayName, UserPrincipalName | Select-Object Id, @{ n = 'Name'; e = { $_.UserPrincipalName } } } if ($Group) { $g = if ($Group -match '^[0-9a-f-]{36}$') { Get-MgGroup -GroupId $Group } else { Get-MgGroup -Filter "displayName eq '$($Group -replace "'", "''")'" } if (@($g).Count -ne 1) { throw "Found $(@($g).Count) groups named '$Group' - use the object ID instead." } $principals += $g | Select-Object Id, @{ n = 'Name'; e = { $_.DisplayName } } } foreach ($p in $principals) { $existing = $assigned | Where-Object PrincipalId -eq $p.Id if ($Remove) { if (-not $existing) { Write-Host "$($p.Name): has no access - nothing to remove"; continue } if ($PSCmdlet.ShouldProcess($p.Name, "Remove $RoleValue")) { Remove-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $sp.Id -AppRoleAssignmentId $existing.Id Write-Host "$($p.Name): access removed" -ForegroundColor Green } } else { if ($existing) { Write-Host "$($p.Name): already has access"; continue } if ($PSCmdlet.ShouldProcess($p.Name, "Assign $RoleValue")) { New-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $sp.Id -PrincipalId $p.Id -ResourceId $sp.Id -AppRoleId $role.Id | Out-Null Write-Host "$($p.Name): access granted - sign in at https://signatures.innovarro.cloud" -ForegroundColor Green } } }