forked from CrowdStrike/psfalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSFalcon.psm1
43 lines (43 loc) · 1.22 KB
/
PSFalcon.psm1
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
36
37
38
39
40
41
42
43
$Public = Get-ChildItem -Path $PSScriptRoot\Public\*.ps1
$Private = Get-ChildItem -Path $PSScriptRoot\Private\Private.ps1
@($Public + $Private).foreach{
try {
. $_.FullName
} catch {
throw $_
}
}
$Data = @{
Endpoints = @{}
ItemTypes = @{}
Parameters = @{}
Patterns = @{}
Schema = @{}
}
($Data.Keys).foreach{
$Key = $_
$DataFiles = if ($_ -eq 'Endpoints') {
Get-ChildItem -Path $PSScriptRoot\Data\$Key\*.psd1
} else {
Get-ChildItem -Path $PSScriptRoot\Data\$Key.psd1
}
($DataFiles).foreach{
try {
(Import-PowerShellDataFile $_.FullName).GetEnumerator().foreach{
$Data.$Key.Add($_.Key, $_.Value)
}
} catch {
throw $_
}
}
}
# Create script variable to contain API, credential and module data
$Script:Falcon = [Falcon]::New($Data)
if ([Net.ServicePointManager]::SecurityProtocol -notmatch 'Tls12') {
# Add TLS2 as .NET SecurityProtocol for communication with APIs
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
}
if ($PSVersionTable.PSVersion.Major -lt 6) {
# Add System.Net.Http in PowerShell Desktop
Add-Type -AssemblyName System.Net.Http
}