Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ApiKey = "rtKJRZHxQYYE4Um8Y-ty"
- $GitLabUrl = "https://gitlab.dev.onsolve.com"
- $Header = @{ "Private-Token"=$ApiKey }
- [int] $retentionPolicy = (-45)
- # GET request function
- function Get-GitLabResource([string]$Uri) {
- Write-Host "[GET]: $GitLabUrl/$Uri"
- return Invoke-RestMethod -Method Get -Uri "$GitLabUrl/$Uri" -Header $Header
- }
- function calcBlockUsers (){
- param(
- [int] $retentionPolicy,
- $userList
- )
- $userList | Where-Object
- }
- # POST request function
- function Post-GitLabResource([string]$Uri, [object]$resource) {
- Write-Host "[POST]: $GitLabUrl/$Uri"
- Invoke-RestMethod -Method Post -Uri "$GitLabUrl/$Uri" -Body $($resource | ConvertTo-Json -Depth 10) -Header $Header
- }
- function changeMonth() {
- param{
- $badDate
- }
- $hardDate = "2019-09-17T08:16:54.940-04:00"
- $monthStr = $hardDate.Substring(5, 2)
- $monthInt = [int]$monthStr
- $monthInt = ($monthInt - 1)
- $monthStr = [String]$monthInt
- if($monthStr.length -lt 2){
- $monthStr.Insert(0,"0")
- }
- Write-Host $monthStr
- $formattedDate = (($hardDate.Substring(0, 5)) + ($monthStr) + ($hardDate.substring(7)))
- Write-Host $formattedDate
- return $formattedDate
- }
- try{
- $userList1 = Get-GitLabResource "api/v4/users?per_page=100&page=1&active=true"
- $userList2 = Get-GitLabResource "api/v4/users?per_page=100&page=2&active=true"
- $userList3 = Get-GitLabResource "api/v4/users?per_page=100&page=3&active=true"
- $userList = $userList1 + $userList2 + $userList3
- $hardDate = "2019-07-17T08:16:54.940-04:00"
- $date = Get-Date -Format o
- Write-Host $date.Substring(5,2)
- Write-Host $date
- #$usersToBlock = $userList | Where-Object { $_.current_sign_in_at -lt $goodDate }
- #Write-Output $usersToBlock.name
- #foreach ($user in $usersToBlock){
- # Post-GitLabResource "api/v4/users/$($user.id)/block"
- #}
- }
- finally{
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement