{"id":21145358,"url":"https://github.com/jsa2/aadrolecheck","last_synced_at":"2025-03-14T13:42:35.363Z","repository":{"id":103263568,"uuid":"393278817","full_name":"jsa2/aadrolecheck","owner":"jsa2","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-06T06:40:12.000Z","size":3,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T07:27:22.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsa2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-06T06:35:45.000Z","updated_at":"2024-10-02T03:53:50.000Z","dependencies_parsed_at":"2023-10-15T13:15:16.431Z","dependency_job_id":null,"html_url":"https://github.com/jsa2/aadrolecheck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2Faadrolecheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2Faadrolecheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2Faadrolecheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2Faadrolecheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsa2","download_url":"https://codeload.github.com/jsa2/aadrolecheck/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243589255,"owners_count":20315467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T08:39:42.918Z","updated_at":"2025-03-14T13:42:35.342Z","avatar_url":"https://github.com/jsa2.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple function to check changes in role assigments of Azure AD \n\nSimple function to show difference between previous and current role assignments\n\n-  PS Output will show the difference when comparing the objects with sideIndicator indicating the difference\n```PowerShell\nCompare-Object -ReferenceObject $existing -DifferenceObject $mbrs;\n```\n```\nInputObject                                                                                                   SideIndicator\n-----------                                                                                                   -------------\n@{ObjectId=c0ba0d53-274c-4f52-ae0a-d50950383fda; DisplayName=https://Recovery-breakglass.dewi.red; userType=} =\u003e\n\n```\n\n## Prerequisites\nConnect-AzureAD with appropriate account and roles \nhttps://docs.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0#directory-roles  \n## Function\n\n```Powershell\nConnect-AzureAD\n# Get the roles you want to be used in the function \nGet-AzureADDirectoryRole\n\n#Roles below for Global admins and Security Reader \n$roles = \"862e258d-ffac-40fd-aa9d-7b2a990c3070,09dc17e0-996d-4b81-ac46-1925550d6ddc\" -split \",\"\n\n#Function will check change in role. If role file does not exist, or import of the file fails, it will overwrite with new file\nfunction RoleChecker ($roleId) {\n\n  $mbrs = Get-AzureADDirectoryRoleMember -ObjectId $role | select -Property ObjectId, DisplayName, userType\n\n try {\nwrite-host \"trying to read existing roles\" -ForegroundColor Green\n$existing = import-csv \"$roleId.csv\"\n\n$diff = Compare-Object -ReferenceObject $existing -DifferenceObject $mbrs;\nWrite-Host \"check diff\" $mbrs.count, \"vs\" $existing.count -ForegroundColor Yellow\n\nif ($diff -and $mbrs ) {\n    write-host \"updating file for id $role\"\n    if ($mbrs) { $mbrs | Export-Csv \"./$role.csv\" -NoTypeInformation -Force}\n    $diff\n}\n\n\n } catch  {\n     write-host \"no existing file creating file\"\n     if ($mbrs) { $mbrs | Export-Csv \"./$role.csv\" -NoTypeInformation -Force}\n    \n }\n\n\n\n}\n\nforeach ($role in $roles) {\n    Write-Host $role\n  RoleChecker -roleId $role\n\n\n}\n``` \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Faadrolecheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsa2%2Faadrolecheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Faadrolecheck/lists"}