-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from kayasax/Groups
Groups
- Loading branch information
Showing
12 changed files
with
1,278 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<# | ||
.Synopsis | ||
List of PIM Entra Role active assignement | ||
.Description | ||
Active assignment does not require to activate their role. https://learn.microsoft.com/en-us/graph/api/rbacapplication-list-roleeligibilityscheduleinstances?view=graph-rest-1.0&tabs=http | ||
.Parameter tenantID | ||
EntraID tenant ID | ||
.Parameter summary | ||
When enabled will return the most useful information only | ||
.PARAMETER rolename | ||
Filter by rolename | ||
.PARAMETER principalid | ||
Filter by principalid | ||
.PARAMETER principalName | ||
Filter by principalName | ||
.Example | ||
PS> Get-PIMEntraRoleActiveAssignment -tenantID $tid | ||
List active assignement | ||
.Link | ||
.Notes | ||
Author: Loïc MICHEL | ||
Homepage: https://github.com/kayasax/EasyPIM | ||
#> | ||
|
||
function Get-PIMGroupActiveAssignment { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Position = 0, Mandatory = $true)] | ||
[String] | ||
$tenantID, | ||
# select the most usefull info only | ||
[switch]$summary, | ||
[string]$groupID, | ||
[string]$rolename, | ||
[string]$principalName | ||
) | ||
|
||
try { | ||
$script:tenantID = $tenantID | ||
|
||
$endpoint = "identityGovernance/privilegedAccess/group/assignmentSchedules?`$filter=groupId eq '$groupID'&`$expand=principal | ||
" | ||
$response = invoke-graph -Endpoint $endpoint | ||
$resu = @() | ||
$response.value | ForEach-Object { | ||
|
||
$r = @{ | ||
#"rolename" = $_.roledefinition.displayName | ||
#"roleid" = $_.roledefinition.id | ||
"principalname" = $_.principal.displayName | ||
"principalid" = $_.principal.id | ||
"principalEmail" = $_.principal.mail | ||
"startDateTime" = $_.scheduleInfo.startDateTime | ||
"endDateTime" = $_.scheduleInfo.expiration.endDateTime | ||
#"directoryScopeId" = $_.directoryScopeId | ||
"memberType" = $_.accessId | ||
"assignmentType" = $_.memberType | ||
#"activatedUsing"=$_.activatedUsing | ||
"principaltype" = $_.principal."@odata.type" | ||
"id" = $_.id | ||
} | ||
$resu += New-Object PSObject -Property $r | ||
|
||
|
||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('summary')) { | ||
$resu = $resu | Select-Object rolename, roleid, principalid, principalName, principalEmail, PrincipalType, startDateTime, endDateTime, directoryScopeId | ||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('principalid')) { | ||
$resu = $resu | Where-Object { $_.principalid -eq $principalid } | ||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('rolename')) { | ||
$resu = $resu | Where-Object { $_.rolename -eq $rolename } | ||
} | ||
if($PSBoundParameters.Keys.Contains('principalName')){ | ||
$resu = $resu | Where-Object { $_.principalName -match $principalName } | ||
} | ||
|
||
return $resu | ||
} | ||
catch { | ||
MyCatch $_ | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<# | ||
.Synopsis | ||
List of PIM Entra Role active assignement | ||
.Description | ||
Active assignment does not require to activate their role. https://learn.microsoft.com/en-us/graph/api/rbacapplication-list-roleeligibilityscheduleinstances?view=graph-rest-1.0&tabs=http | ||
.Parameter tenantID | ||
EntraID tenant ID | ||
.Parameter summary | ||
When enabled will return the most useful information only | ||
.PARAMETER rolename | ||
Filter by rolename | ||
.PARAMETER principalid | ||
Filter by principalid | ||
.PARAMETER principalName | ||
Filter by principalName | ||
.Example | ||
PS> Get-PIMEntraRoleActiveAssignment -tenantID $tid | ||
List active assignement | ||
.Link | ||
.Notes | ||
Author: Loïc MICHEL | ||
Homepage: https://github.com/kayasax/EasyPIM | ||
#> | ||
|
||
function Get-PIMGroupEligibleAssignment { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Position = 0, Mandatory = $true)] | ||
[String] | ||
$tenantID, | ||
# select the most usefull info only | ||
[switch]$summary, | ||
[string]$groupID, | ||
[string]$rolename, | ||
[string]$principalName | ||
) | ||
|
||
try { | ||
$script:tenantID = $tenantID | ||
|
||
$endpoint = "identityGovernance/privilegedAccess/group/eligibilitySchedules?`$filter=groupId eq '$groupID'&`$expand=principal | ||
" | ||
$response = invoke-graph -Endpoint $endpoint | ||
$resu = @() | ||
$response.value | ForEach-Object { | ||
|
||
$r = @{ | ||
#"rolename" = $_.roledefinition.displayName | ||
##"roleid" = $_.roledefinition.id | ||
"principalname" = $_.principal.displayName | ||
"principalid" = $_.principal.id | ||
"principalEmail" = $_.principal.mail | ||
"startDateTime" = $_.scheduleInfo.startDateTime | ||
"endDateTime" = $_.scheduleInfo.expiration.endDateTime | ||
#"directoryScopeId" = $_.directoryScopeId | ||
"memberType" = $_.accessId | ||
"assignmentType" = $_.memberType | ||
#"activatedUsing"=$_.activatedUsing | ||
"principaltype" = $_.principal."@odata.type" | ||
"id" = $_.id | ||
} | ||
$resu += New-Object PSObject -Property $r | ||
|
||
|
||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('summary')) { | ||
$resu = $resu | Select-Object rolename, roleid, principalid, principalName, principalEmail, PrincipalType, startDateTime, endDateTime, directoryScopeId | ||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('principalid')) { | ||
$resu = $resu | Where-Object { $_.principalid -eq $principalid } | ||
} | ||
|
||
if ($PSBoundParameters.Keys.Contains('rolename')) { | ||
$resu = $resu | Where-Object { $_.rolename -eq $rolename } | ||
} | ||
if($PSBoundParameters.Keys.Contains('principalName')){ | ||
$resu = $resu | Where-Object { $_.principalName -match $principalName } | ||
} | ||
|
||
return $resu | ||
} | ||
catch { | ||
MyCatch $_ | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<# | ||
.Synopsis | ||
EASYPIM | ||
Powershell module to manage PIM Azure Resource Role settings with simplicity in mind | ||
Get-PIMGroupPolicy will return the policy rules (like require MFA on activation) of the selected rolename at the subscription level | ||
Support querrying multi roles at once | ||
.Description | ||
Get-PIMGroupPolicy will use the Microsoft Graph APIs to retrieve the PIM settings of the role $rolename | ||
.PARAMETER tenantID | ||
Tenant ID | ||
.PARAMETER GroupID | ||
Id of the group to check | ||
.PARAMETER GroupName | ||
Search for the group by name | ||
.Example | ||
PS> Get-PIMGroupPolicy -tenantID $tenantID -rolename "Global Administrator","Global Reader" | ||
show curent config for the roles global administrator and global reader | ||
.Link | ||
https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-rest-api | ||
https://learn.microsoft.com/en-us/graph/identity-governance-pim-rules-overview | ||
Duration ref https://en.wikipedia.org/wiki/ISO_8601#Durations | ||
.Notes | ||
Homepage: https://github.com/kayasax/easyPIM | ||
Author: MICHEL, Loic | ||
Changelog: | ||
Todo: | ||
* allow other scopes | ||
#> | ||
function Get-PIMGroupPolicy { | ||
[CmdletBinding()] | ||
[OutputType([PSCustomObject])] | ||
param ( | ||
|
||
[Parameter(Position = 0, Mandatory = $true)] | ||
[System.String] | ||
# Tenant ID | ||
$tenantID, | ||
|
||
[Parameter(Position = 1)] | ||
[System.String[]] | ||
# Array of role name | ||
$groupID, | ||
|
||
[Parameter(Position = 2)] | ||
[System.String] | ||
# Array of role name | ||
$groupName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
#owner or member | ||
$type | ||
|
||
|
||
) | ||
try { | ||
$script:tenantID = $tenantID | ||
|
||
if ($PSBoundParameters.ContainsKey('groupname')) { | ||
$endpoint="/groups?`$filter=startswith(displayName,'$($groupName)')" | ||
$response=invoke-graph -Endpoint $endpoint | ||
$groupID+=$response.value.id | ||
|
||
} | ||
|
||
|
||
$out = @() | ||
$groupID | ForEach-Object { | ||
|
||
#get curent config | ||
$config = get-GroupConfig $_ $type | ||
$out += $config | ||
} | ||
Write-Output $out -NoEnumerate | ||
} | ||
catch { | ||
MyCatch $_ | ||
} | ||
|
||
} |
This file contains 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
Oops, something went wrong.