# 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 {
        HelpMessage="Enter the user ID of the user you want to collect information on.")]
    Get-MGUser -UserId $UserID | Format-List
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter