PSKB4.psm1
#Region '.\Public\Get-Kb4Event.ps1' -1 function Get-Kb4Event { <# .SYNOPSIS This endpoint retrieves a list of all events in your KnowBe4 account .DESCRIPTION This endpoint retrieves a list of all events in your KnowBe4 account .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventId Target Event Id .EXAMPLE Get-Kb4Event -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$EventId ) begin { [string]$endpoint = "$($Uri)/events" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("EventId")) { $url = "$($endpoint)/$($EventId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) if ($($response.meta.is_last_page -eq "True") -or $($response.meta.is_out_of_range -eq "True" -or $($response.data.count -eq 0)) ) { break } } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4Event.ps1' 82 #Region '.\Public\Get-Kb4EventStatus.ps1' -1 function Get-Kb4EventStatus { <# .SYNOPSIS This endpoint retrieves all of the event statuses in your KnowBe4 account. .DESCRIPTION This endpoint retrieves all of the event statuses in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventStatusId Target Event Status ID .EXAMPLE Get-Kb4EventStatus -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$EventStatusId ) begin { [string]$endpoint = "$($Uri)/statuses" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("EventStatusId")) { $url = "$($endpoint)/$($EventStatusId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) if ($($response.meta.is_last_page -eq "True") -or $($response.meta.is_out_of_range -eq "True" -or $($response.data.count -eq 0)) ) { break } } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4EventStatus.ps1' 81 #Region '.\Public\Get-Kb4EventType.ps1' -1 function Get-Kb4EventType { <# .SYNOPSIS This endpoint retrieves a list of all event types in your KnowBe4 account. .DESCRIPTION This endpoint retrieves a list of all event types in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventTypeId Target Event Type ID .EXAMPLE Get-Kb4EventType -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$EventTypeId ) begin { [string]$endpoint = "$($Uri)/event_types" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("EventTypeId")) { $url = "$($endpoint)/$($EventTypeId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) if ($($response.meta.is_last_page -eq "True") -or $($response.meta.is_out_of_range -eq "True" -or $($response.data.count -eq 0)) ) { break } } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4EventType.ps1' 81 #Region '.\Public\Get-Kb4ReportingAccountAndSubscriptionData.ps1' -1 function Get-Kb4ReportingAccountAndSubscriptionData { <# .SYNOPSIS This endpoint retrieves account data from you Knowbe4 account, including your subscription level, number of seats, risk score history, and more. .DESCRIPTION This endpoint retrieves account data from you Knowbe4 account, including your subscription level, number of seats, risk score history, and more. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .EXAMPLE Get-Kb4ReportingAccountAndSubscriptionData -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token ) begin { $endpoint = "$($Uri)/v1/account" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } } process { try { $response = Invoke-RestMethod -Uri $endpoint -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } } end { return $response } } #EndRegion '.\Public\Get-Kb4ReportingAccountAndSubscriptionData.ps1' 51 #Region '.\Public\Get-Kb4ReportingAccountRiskScoreHistory.ps1' -1 function Get-Kb4ReportingAccountRiskScoreHistory { <# .SYNOPSIS This endpoint retrieves your Knowbe4 account risk score history. .DESCRIPTION This endpoint retrieves your Knowbe4 account risk score history. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .EXAMPLE Get-Kb4ReportingAccountRiskScoreHistory -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token ) begin { [int]$page = 1 [string]$endpoint = "$($Uri)/v1/account/risk_score_history" [System.Collections.ArrayList]$Output = @() [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } } process { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingAccountRiskScoreHistory.ps1' 57 #Region '.\Public\Get-Kb4ReportingGroup.ps1' -1 function Get-Kb4ReportingGroup { <# .SYNOPSIS This endpoint retrieves a list of all groups in your KnowBe4 account. .DESCRIPTION This endpoint retrieves a list of all groups in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER GroupId Target Group Id .EXAMPLE Get-Kb4ReportingGroup -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$GroupId ) begin { [string]$endpoint = "$($Uri)/v1/groups" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("GroupId")) { $url = "$($endpoint)/$($GroupId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingGroup.ps1' 78 #Region '.\Public\Get-Kb4ReportingGroupMember.ps1' -1 function Get-Kb4ReportingGroupMember { <# .SYNOPSIS This endpoint retrieves a list of all users who are members of a specific group. .DESCRIPTION This endpoint retrieves a list of all users who are members of a specific group. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER GroupId Target Group Id .EXAMPLE Get-Kb4ReportingGroupMember -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$GroupId ) begin { [string]$endpoint = "$($Uri)/v1/groups/$($GroupId)/members" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingGroupMember.ps1' 66 #Region '.\Public\Get-Kb4ReportingGroupRiskScore.ps1' -1 function Get-Kb4ReportingGroupRiskScore { <# .SYNOPSIS This endpoint retrieves risk score history for a specific group in your KnowBe4 account, based on the provided group identifier .DESCRIPTION This endpoint retrieves risk score history for a specific group in your KnowBe4 account, based on the provided group identifier .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER GroupId Target Group Id .EXAMPLE Get-Kb4ReportingGroupRiskScore -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$GroupId ) begin { [string]$endpoint = "$($Uri)/v1/groups/$($GroupId)/risk_score_history" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingGroupRiskScore.ps1' 66 #Region '.\Public\Get-Kb4ReportingPhishingCampaign.ps1' -1 function Get-Kb4ReportingPhishingCampaign { <# .SYNOPSIS This endpoint retrieves data from a specific phishing campaign, based on the provided campaign identifier .DESCRIPTION This endpoint retrieves data from a specific phishing campaign, based on the provided campaign identifier .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER CampaignId Target Campaign Id .EXAMPLE Get-Kb4ReportingPhishingCampaign -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$CampaignId ) begin { [string]$endpoint = "$($Uri)/v1/phishing/campaigns" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("CampaignId")) { $url = "$($endpoint)/$($CampaignId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingPhishingCampaign.ps1' 79 #Region '.\Public\Get-Kb4ReportingPhishingSecurityTest.ps1' -1 function Get-Kb4ReportingPhishingSecurityTest { <# .SYNOPSIS This endpoint retrieves a list of all phishing security tests in your account. .DESCRIPTION This endpoint retrieves a list of all phishing security tests in your account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER PhishingSecurityTestId Target Security Test Id .EXAMPLE Get-Kb4ReportingPhishingSecurityTest -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$PhishingSecurityTestId ) begin { [string]$endpoint = "$($Uri)/v1/phishing/security_tests" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("PhishingSecurityTestId")) { $url = "$($endpoint)/$($PhishingSecurityTestId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingPhishingSecurityTest.ps1' 78 #Region '.\Public\Get-Kb4ReportingPhishingSecurityTestForCampaign.ps1' -1 function Get-Kb4ReportingPhishingSecurityTestForCampaign { <# .SYNOPSIS This endpoint retrieves a list of all phishing security tests from a specific phishing campaign, based on the provided phishing campaign identifier .DESCRIPTION This endpoint retrieves a list of all phishing security tests from a specific phishing campaign, based on the provided phishing campaign identifier .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER CampaignId Target Campaign Id .EXAMPLE Get-Kb4ReportingPhishingSecurityTestForCampaign -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory)] [ValidateNotNullOrWhiteSpace()] [string]$CampaignId ) begin { [string]$endpoint = "$($Uri)/v1/phishing/campaigns/$($CampaignId)/security_tests" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingPhishingSecurityTestForCampaign.ps1' 66 #Region '.\Public\Get-Kb4ReportingPhishingSecurityTestRecipient.ps1' -1 function Get-Kb4ReportingPhishingSecurityTestRecipient { <# .SYNOPSIS This endpoint retrieves details about a specific user's phishing security test results, based on the provided phishing security test identifier (pst_id) and recipient identifier .DESCRIPTION This endpoint retrieves details about a specific user's phishing security test results, based on the provided phishing security test identifier (pst_id) and recipient identifier .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER PhishingSecurityTestId Target Security test ID .PARAMETER RecipientId Target recipient ID .EXAMPLE Get-Kb4ReportingPhishingSecurityTestRecipient -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as".EXAMPLE #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$PhishingSecurityTestId, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$RecipientId ) begin { [string]$endpoint = "$($Uri)/v1/phishing/security_tests/$($PhishingSecurityTestId)/recipients" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.ContainsKey("RecipientId")) { $url = "$($endpoint)/$($RecipientId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingPhishingSecurityTestRecipient.ps1' 84 #Region '.\Public\Get-Kb4ReportingTrainingCampaign.ps1' -1 function Get-Kb4ReportingTrainingCampaign { <# .SYNOPSIS This endpoint retrieves a list of all Training Campaigns in your KnowBe4 account. .DESCRIPTION This endpoint retrieves a list of all Training Campaigns in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER TrainingCampaignId Target Traning campaign Id .EXAMPLE Get-Kb4ReportingTrainingCampaign -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$TrainingCampaignId ) begin { [string]$endpoint = "$($Uri)/v1/training/campaigns" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("TrainingCampaignId")) { $url = "$($endpoint)/$($TrainingCampaignId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingTrainingCampaign.ps1' 78 #Region '.\Public\Get-Kb4ReportingTrainingEnrollment.ps1' -1 function Get-Kb4ReportingTrainingEnrollment { <# .SYNOPSIS This endpoint retrieves a list of all Training Enrollments in your KnowBe4 account. .DESCRIPTION This endpoint retrieves a list of all Training Enrollments in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER TrainingEnrollmentId Target Training enrollment Id .EXAMPLE Get-Kb4ReportingTrainingEnrollment -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$TrainingEnrollmentId ) begin { [string]$endpoint = "$($Uri)/v1/training/enrollments" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("TrainingEnrollmentId")) { $url = "$($endpoint)/$($TrainingEnrollmentId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingTrainingEnrollment.ps1' 78 #Region '.\Public\Get-Kb4ReportingTrainingPolicy.ps1' -1 function Get-Kb4ReportingTrainingPolicy { <# .SYNOPSIS This endpoint retrieves a specific uploaded policy from your KnowBe4 account. .DESCRIPTION This endpoint retrieves a specific uploaded policy from your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER PolicyId Target Policy Id .EXAMPLE Get-Kb4ReportingTrainingPolicy -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$PolicyId ) begin { [string]$endpoint = "$($Uri)/v1/training/policies" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("PolicyId")) { $url = "$($endpoint)/$($PolicyId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingTrainingPolicy.ps1' 78 #Region '.\Public\Get-Kb4ReportingTrainingStorePurchase.ps1' -1 function Get-Kb4ReportingTrainingStorePurchase { <# .SYNOPSIS This endpoint retrieves a list of all Store Purchases in your KnowBe4 account .DESCRIPTION This endpoint retrieves a list of all Store Purchases in your KnowBe4 account .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER StorePurchaseId Target Store purchase Id .EXAMPLE Get-Kb4ReportingTrainingStorePurchase -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$StorePurchaseId ) begin { [string]$endpoint = "$($Uri)/v1/training/store_purchases" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("StorePurchaseId")) { $url = "$($endpoint)/$($StorePurchaseId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingTrainingStorePurchase.ps1' 78 #Region '.\Public\Get-Kb4ReportingUser.ps1' -1 function Get-Kb4ReportingUser { <# .SYNOPSIS This endpoint retrieves a list of all users in your KnowBe4 account .DESCRIPTION This endpoint retrieves a list of all users in your KnowBe4 account .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER UserId Target User Id .EXAMPLE Get-Kb4ReportingUser -Uri "https://us.api.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter()] [ValidateNotNullOrWhiteSpace()] [string]$UserId ) begin { [string]$endpoint = "$($Uri)/v1/users" [int]$page = 1 [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("UserId")) { $url = "$($endpoint)/$($UserId)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } else { do { $url = "$($endpoint)?page=$($page)" try { $response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } $page ++ [void]$Output.Add($response) } while ($response.count -gt 0) } } end { return $Output } } #EndRegion '.\Public\Get-Kb4ReportingUser.ps1' 77 #Region '.\Public\New-Kb4Event.ps1' -1 function New-Kb4Event { <# .SYNOPSIS This endpoint creates a single event or a batch of events for your user(s). This information will be pushed into your KnowBe4 account. Be aware that events must be processed by the KSAT server and may not immediately display in your account .DESCRIPTION This endpoint creates a single event or a batch of events for your user(s). This information will be pushed into your KnowBe4 account. Be aware that events must be processed by the KSAT server and may not immediately display in your account .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER TargetUser The user's email address. .PARAMETER EventType If the event type does not already exist, the value entered here will be used to create a new event type. .PARAMETER ExternalId Include a custom External ID. .PARAMETER Source Include a custom Source. .PARAMETER Description A description of the event (Max = 255 characters). .PARAMETER OccurredDate If a date is not set, this field will default to the current time (UTC). .PARAMETER RiskLevel Assign a value from -10 (low risk) to 10 (high risk). .PARAMETER RiskDecayMode Assign a value of 0 or 1. Values outside of this range will not be factored into the risk decay mode. 0 = Risk Level becomes 0 at risk_expire_date 1 = Risk Level decays linearly to 0 by risk_expire_date .PARAMETER RiskExpireDate If a date is not set, this field will default to the occurred_date plus one (1) month. .EXAMPLE New-Kb4Event -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" -TargetUser "user@example.com" -EventType "MyEvent" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [ValidateScript({ if ($PSItem -inotmatch '(?:(?!.*?[.]{2})[a-zA-Z0-9](?:[a-zA-Z0-9.+!%-]{1,64}|)|\"[a-zA-Z0 - 9. + ! % - ] { 1, 64 }\")@[a-zA-Z0-9][a-zA-Z0-9.-]+(.[a-z]{2,}|.[0-9]{1,})') { throw "Invalid Email address" } return $true })] [string]$TargetUser, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 64)] [string]$EventType, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 64)] [string]$ExternalId, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 64)] [string]$Source, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 254)] [string]$Description, [Parameter()] [ValidateNotNullOrWhiteSpace()] [datetime]$OccurredDate, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateRange(-10, 10)] [int]$RiskLevel, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateSet(0, 1)] [int]$RiskDecayMode, [Parameter()] [ValidateNotNullOrWhiteSpace()] [datetime]$RiskExpireDate ) begin { [string]$Url = "$($Uri)/events" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [hashtable]$Body = @{ target_user = "$($TargetUser)" event_type = "$($EventType)" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("ExternalId")) { $Body["external_id"] = "$($ExternalId)" } if ($PSBoundParameters.containskey("Source")) { $Body["source"] = "$($Source)" } if ($PSBoundParameters.containskey("Description")) { $Body["description"] = "$($Description)" } if ($PSBoundParameters.containskey("OccurredDate")) { $Body["occurred_date"] = "$($OccurredDate.ToString('yyyy-MM-dd'))" } if ($PSBoundParameters.containskey("RiskLevel")) { $Body["risk_level"] = $RiskLevel } if ($PSBoundParameters.containskey("RiskDecayModeRiskLevel")) { $Body["risk_decay_mode"] = "$($RiskDecayMode)" } if ($PSBoundParameters.containskey("RiskExpireDate")) { $Body["risk_expire_date"] = "$($RiskExpireDate.ToString('yyyy-MM-dd'))" } try { $response = Invoke-RestMethod -Uri $Url -Headers $header -Body ($Body | ConvertTo-Json -Depth 99) -Method Post -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } end { return $Output } } #EndRegion '.\Public\New-Kb4Event.ps1' 162 #Region '.\Public\New-Kb4EventType.ps1' -1 function New-Kb4EventType { <# .SYNOPSIS This endpoint creates a new event type. This information will be pushed into your KnowBe4 account. .DESCRIPTION This endpoint creates a new event type. This information will be pushed into your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER Name The name of the event type .PARAMETER Description A description of the event type (Max = 255 characters). .EXAMPLE New-Kb4EventType -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" -Name "My Event Type" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 64)] [string]$Name, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 254)] [string]$Description ) begin { [string]$Url = "$($Uri)/event_types" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [hashtable]$Body = @{ name = "$($Name)" } [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("Description")) { $Body["description"] = "$($Description)" } try { $response = Invoke-RestMethod -Uri $Url -Headers $header -Body ($Body | ConvertTo-Json -Depth 99) -Method Post -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } end { return $Output } } #EndRegion '.\Public\New-Kb4EventType.ps1' 80 #Region '.\Public\Remove-Kb4Event.ps1' -1 function Remove-Kb4Event { <# .SYNOPSIS This endpoint deletes a single event based on the ID supplied. .DESCRIPTION This endpoint deletes a single event based on the ID supplied. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventId The ID of the event to delete. .EXAMPLE Remove-Kb4Event -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" -EventId 1 #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [int]$EventId ) begin { [string]$Url = "$($Uri)/events/$($EventId)" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { try { $response = Invoke-RestMethod -Uri $Url -Headers $header -Method Delete -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } end { return $Output } } #EndRegion '.\Public\Remove-Kb4Event.ps1' 64 #Region '.\Public\Remove-Kb4EventType.ps1' -1 function Remove-Kb4EventType { <# .SYNOPSIS This endpoint deletes a single event type based on the ID supplied. .DESCRIPTION This endpoint deletes a single event type based on the ID supplied. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventTypeId Target event type id .EXAMPLE Remove-Kb4EventType -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" -EventTypeId 1 #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [int]$EventTypeId ) begin { [string]$Url = "$($Uri)/event_types/$($EventTypeId)" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [System.Collections.ArrayList]$Output = @() } process { try { $response = Invoke-RestMethod -Uri $Url -Headers $header -Method Delete -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } end { return $Output } } #EndRegion '.\Public\Remove-Kb4EventType.ps1' 61 #Region '.\Public\Update-Kb4EventType.ps1' -1 function Update-Kb4EventType { <# .SYNOPSIS This endpoint updates information about an existing event type in your KnowBe4 account. .DESCRIPTION This endpoint updates information about an existing event type in your KnowBe4 account. .PARAMETER Uri Base api Url based on the location .PARAMETER Token JWT token for the api .PARAMETER EventTypeId Target Event Type ID .PARAMETER Name The name of the event type. .PARAMETER Description A description of the event type (Max = 255 characters). .EXAMPLE Update-Kb4EventType -Uri "https://api.events.knowbe4.com" -Token "0afsd8f0asfdas98duf0as9duf0asd9f.a0df98as0dfha0s8dfha0sdfh0as.as0dfh8as0d8fha0sfdh0as" -EventTypeId 1 -Name "My Event Type" #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Uri, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [string]$Token, [Parameter(Mandatory = $true)] [ValidateNotNullOrWhiteSpace()] [int]$EventTypeId, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 64)] [string]$Name, [Parameter()] [ValidateNotNullOrWhiteSpace()] [ValidateLength(1, 254)] [string]$Description ) begin { [string]$Url = "$($Uri)/event_types/$($EventTypeId)" [hashtable]$header = @{ "Authorization" = "Bearer $($Token)" "Accept" = "application/json" } [hashtable]$Body = @{} [System.Collections.ArrayList]$Output = @() } process { if ($PSBoundParameters.containskey("Name")) { $Body["name"] = "$($Name)" } if ($PSBoundParameters.containskey("Description")) { $Body["description"] = "$($Description)" } try { $response = Invoke-RestMethod -Uri $Url -Headers $header -Body ($Body | ConvertTo-Json -Depth 99) -Method Put -ContentType "application/json" -ErrorAction Stop } catch { throw $_ } [void]$Output.Add($response) } end { return $Output } } #EndRegion '.\Public\Update-Kb4EventType.ps1' 88 |