-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredentials.ps1
More file actions
30 lines (20 loc) · 915 Bytes
/
credentials.ps1
File metadata and controls
30 lines (20 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#Requires -Modules @{ ModuleName="Microsoft.Graph.Authentication"; ModuleVersion="2.13.1" }
#Requires -Modules @{ ModuleName="Microsoft.Graph.Applications"; ModuleVersion="2.13.1" }
$ErrorActionPreference = 'stop'
<#
.SYNOPSIS
Find all application registrations with credentials.
.DESCRIPTION
.NOTES
AUTHOR: https://github.com/dwarfered/msgraph-sdk-powershell-examples
UPDATED: 15-02-2024
#>
$requiredScopes = @('Application.Read.All')
$currentScopes = (Get-MgContext).Scopes
if ($null -eq $currentScopes) {
Connect-MgGraph -Scopes $requiredScopes | Out-Null
} elseif (($currentScopes -match ([string]::Join('|', $requiredScopes))).Count -ne $requiredScopes.Count) {
Connect-MgGraph -Scopes $requiredScopes | Out-Null
}
$applications = Get-MgApplication -All -PageSize 999
| Where-Object { $_.KeyCredentials -ne $null -or $_.PasswordCredentials -ne $null }