-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMSGraphRequest.psm1
More file actions
35 lines (30 loc) · 1.28 KB
/
MSGraphRequest.psm1
File metadata and controls
35 lines (30 loc) · 1.28 KB
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
28
29
30
31
32
33
34
35
<#
.SYNOPSIS
Script that initiates the MSGraphRequest module
.NOTES
Author: Nickolaj Andersen & Jan Ketil Skanke
Contact: @NickolajA & @JankeSkanke
Website: https://www.msendpointmgr.com
#>
[CmdletBinding()]
param()
process {
# Initialize script-scoped connection state
$script:MSGraphConnection = $null
$script:AuthenticationHeader = $null
# Locate all the public and private function specific files
$PublicFunctions = Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath "Public") -Filter "*.ps1" -ErrorAction SilentlyContinue
$PrivateFunctions = Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath "Private") -Filter "*.ps1" -ErrorAction SilentlyContinue
# Dot source the function files
foreach ($FunctionFile in @($PublicFunctions + $PrivateFunctions)) {
try {
. $FunctionFile.FullName -ErrorAction Stop
}
catch [System.Exception] {
Write-Error -Message "Failed to import function '$($FunctionFile.FullName)' with error: $($_.Exception.Message)"
}
}
# Backward-compatibility alias - log deprecation warning when used
Set-Alias -Name "Get-AccessToken" -Value "Connect-MSGraphRequest"
Export-ModuleMember -Function $PublicFunctions.BaseName -Alias *
}