Private/Write-MEMLog.ps1
Function Write-MEMLog { <# .SYNOPSIS This function is used to authenticate with the Graph API REST interface .DESCRIPTION The function authenticate with the Graph API Interface with the tenant name .EXAMPLE Get-AuthTokenMSAL Authenticates you with the Graph API interface using MSAL.PS module .NOTES NAME: Get-AuthTokenMSAL #> [cmdletbinding()] Param( [parameter(Mandatory = $true)] [String]$Path, [parameter(Mandatory = $true)] [String]$Message, [parameter(Mandatory = $true)] [String]$Component, [Parameter(Mandatory = $true)] [ValidateSet('Info', 'Warning', 'Error')] [String]$Type ) switch ($Type) { 'Info' { [int]$Type = 1 } 'Warning' { [int]$Type = 2 } 'Error' { [int]$Type = 3 } } # Create a log entry $Content = "<![LOG[$Message]LOG]!>" + ` "<time=`"$(Get-Date -Format 'HH:mm:ss.ffffff')`" " + ` "date=`"$(Get-Date -Format 'M-d-yyyy')`" " + ` "component=`"$Component`" " + ` "context=`"$([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)`" " + ` "type=`"$Type`" " + ` "thread=`"$([Threading.Thread]::CurrentThread.ManagedThreadId)`" " + ` "file=`"`">" # Write the line to the log file Add-Content -Path $Path -Value $Content } |