Skip to content

Commit

Permalink
Merge pull request #51 from kayasax/reporting
Browse files Browse the repository at this point in the history
V1.6.2
  • Loading branch information
kayasax authored Jun 5, 2024
2 parents fdd2744 + 185cc5e commit bd59776
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
LOGS
TEST
TESTS
EXPORTS
*.csv
TestResults
2 changes: 1 addition & 1 deletion EasyPIM/EasyPIM.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'EasyPIM.psm1'

# Version number of this module.
ModuleVersion = '1.6.1'
ModuleVersion = '1.6.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion EasyPIM/functions/Set-PIMEntraRolePolicy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Set-PIMEntraRolePolicy {
}
$p = $p -join ', '

log "Function Set-PIMEntraRolePolicy is starting with parameters: $p" -noEcho
write-verbose "Function Set-PIMEntraRolePolicy is starting with parameters: $p"

$script:tenantID=$tenantID

Expand Down
19 changes: 17 additions & 2 deletions EasyPIM/functions/Show-PIMReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ function Show-PIMReport {
[Parameter(Position = 0, Mandatory = $true)]
[System.String]
# Tenant ID
$tenantID
$tenantID,
[Parameter(Position = 1, Mandatory = $false)]
[System.String]
# upn of the user
$upn

)
try {
$Script:tenantID = $tenantID
Expand All @@ -32,7 +37,6 @@ function Show-PIMReport {
#$top = 100
$endpoint = "auditlogs/directoryAudits?`$filter=loggedByService eq 'PIM'" #&`$top=$top"
$result = invoke-graph -Endpoint $endpoint -Method "GET"

$allresults += $result.value

if ($result."@odata.nextLink") {
Expand All @@ -48,6 +52,17 @@ function Show-PIMReport {

#filter activities from the PIM service and completed activities
$allresults = $allresults | Where-Object { $null -ne $_.initiatedby.values.userprincipalname } | Where-Object { $_.activityDisplayName -notmatch "completed" }

#check if upn parameter is set using psboundparameters
if ($PSBoundParameters.ContainsKey('upn')) {
Write-Verbose "Filtering activities for $upn"
$allresults = $allresults | Where-Object {$_.initiatedby.values.userprincipalname -eq $upn}
if ($allresults.count -eq 0) {
Write-Warning "No activity found for $upn"
return
}
}

$Myoutput = @()

$allresults | ForEach-Object {
Expand Down
4 changes: 4 additions & 0 deletions EasyPIM/internal/functions/get-EntraRoleConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function Get-EntraRoleConfig ($rolename) {
$response = invoke-graph -Endpoint $endpoint
$roleID = $response.value.Id
Write-Verbose "roleID = $roleID"
if($null -eq $roleID){
Throw "ERROR: Role $rolename not found"
return
}

# 2 Get PIM policyID for that role
$endpoint = "policies/roleManagementPolicyAssignments?`$filter=scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq '$roleID'"
Expand Down

0 comments on commit bd59776

Please sign in to comment.