# Ms Graph Functions
# Connect to MG Graph with Read-only permissions.
function Connect-ToMSGraph-ReadOnlyPerms {
Connect-MgGraph "User.Read.All", "DeviceManagementRBAC.Read.All", "DeviceManagementServiceConfig.Read.All", "DeviceManagementConfiguration.Read.All", "DeviceManagementManagedDevices.Read.All"
}
# Grab basic user information to work with.
function Get-BasicUserinfo {
Get-MGUser -All -Property Id, DisplayName, UserPrincipalName, AssignedLicenses | Select Id, DisplayName, UserPrincipalName, AssignedLicenses
}
# Grab a password report of all users.
Function Get-UserPWreport {
Get-MgUser -All -Property UserPrincipalName, DisplayName, Id, LastPasswordChangeDateTime,PasswordPolicies | Select-Object UserPrincipalName, DisplayName, LastPasswordChangeDateTime,PasswordPolicies, @{l='PasswordAgeDays';e={ (New-TimeSpan -Start $_.LastPasswordChangeDateTime -End (get-date) ).TotalDays -as [int] }} | Sort-Object PasswordAgeDays
}
# Grab all avaialble properties for a specific user.
function Get-SpecifcUserFullInfo {
[CmdletBinding()]
param(
[Parameter(Mandatory,
HelpMessage="Enter the user ID of the user you want to collect information on.")]
[string[]]$UserID
)
Get-MGUser -UserId $UserID | Format-List
}