-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Audit event tweaks and sample report
- Loading branch information
1 parent
fd5b4fc
commit a04a943
Showing
4 changed files
with
55 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function Get-GitlabMembershipReport { | ||
param( | ||
[string] | ||
[Parameter(Mandatory, Position=0)] | ||
$GroupName, | ||
|
||
[string] | ||
[Parameter(Mandatory)] | ||
$StartDate, | ||
|
||
[string] | ||
[Parameter()] | ||
$EndDate | ||
) | ||
|
||
$Group = Get-GitlabGroup $GroupName | ||
|
||
$CurrentMembership = $Group | Get-GitlabGroupMember | ||
$AuditRequest = @{ | ||
GroupId = $Group.Id | ||
All = $true | ||
FetchAuthors = $true | ||
After = $StartDate | ||
} | ||
if ($EndDate) { | ||
Before = $EndDate | ||
} | ||
|
||
Write-Host "Current membership of '$GroupName' on $(Get-Date):" | ||
$CurrentMembership | Foreach-Object { | ||
[PSCustomObject]@{ | ||
'User' = $_.Name | ||
'Access' = $_.AccessLevelFriendly | ||
'Granted On' = $_.CreatedAt | ||
} | ||
} | Format-Markdown | ||
Write-Host "`nChanges to membership since $StartDate`:" | ||
Get-GitlabAuditEvent @AuditRequest | | ||
Where-Object { $_.Details.add -eq 'user_access' -or $_.Details.remove -eq 'user_access' -or $_.Details.change -eq 'access_level' } | | ||
ForEach-Object { | ||
[PSCustomObject]@{ | ||
Timestamp = $_.CreatedAt | ||
User = $_.Author.Name | ||
Action = $_.Summary | ||
} | ||
} | Format-Markdown | ||
} |
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
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