├── 1.0.0 ├── psExtrahop.psd1 ├── Private │ └── SupportFunctions.psm1 └── Public │ ├── AuditLog.psm1 │ ├── activitygroups.psm1 │ ├── appliance.psm1 │ ├── triggers.psm1 │ ├── PacketCapture.psm1 │ ├── apikeys.psm1 │ ├── Detections.psm1 │ ├── nodes.psm1 │ ├── Whitelists.psm1 │ ├── vLans.psm1 │ ├── Dashboards.psm1 │ ├── RunningConfig.psm1 │ ├── Bundles.psm1 │ ├── Customizations.psm1 │ ├── Users.psm1 │ └── Tags.psm1 ├── 1.0.1 ├── psExtrahop.psd1 ├── Private │ └── SupportFunctions.psm1 └── Public │ ├── AuditLog.psm1 │ ├── activitygroups.psm1 │ ├── appliance.psm1 │ ├── triggers.psm1 │ ├── PacketCapture.psm1 │ ├── apikeys.psm1 │ ├── Detections.psm1 │ ├── nodes.psm1 │ ├── Whitelists.psm1 │ ├── vLans.psm1 │ ├── Dashboards.psm1 │ ├── RunningConfig.psm1 │ ├── Bundles.psm1 │ ├── Customizations.psm1 │ ├── Users.psm1 │ └── Tags.psm1 └── README.md /1.0.0/psExtrahop.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hematic/psExtrahop/HEAD/1.0.0/psExtrahop.psd1 -------------------------------------------------------------------------------- /1.0.1/psExtrahop.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hematic/psExtrahop/HEAD/1.0.1/psExtrahop.psd1 -------------------------------------------------------------------------------- /1.0.0/Private/SupportFunctions.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopHeaders{ 2 | <# 3 | .SYNOPSIS 4 | Function to create the Extrahop Headers 5 | .DESCRIPTION 6 | This function extracts the code for header creation from each individual function for cleanliness purposes. 7 | .EXAMPLE 8 | New-ExtrahopHeaders -apiKey $apiKey 9 | #> 10 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 11 | Param( 12 | [String]$apiKey = '' 13 | ) 14 | $Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" 15 | $Headers.Add('Authorization',("ExtraHop apikey=$apiKey")) 16 | $Headers.Add('Accept','application/json') 17 | 18 | Return $headers 19 | } -------------------------------------------------------------------------------- /1.0.1/Private/SupportFunctions.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopHeaders{ 2 | <# 3 | .SYNOPSIS 4 | Function to create the Extrahop Headers 5 | .DESCRIPTION 6 | This function extracts the code for header creation from each individual function for cleanliness purposes. 7 | .EXAMPLE 8 | New-ExtrahopHeaders -apiKey $apiKey 9 | #> 10 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 11 | Param( 12 | [String]$apiKey = '' 13 | ) 14 | $Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" 15 | $Headers.Add('Authorization',("ExtraHop apikey=$apiKey")) 16 | $Headers.Add('Accept','application/json') 17 | 18 | Return $headers 19 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # psExtrahop 2 | PowerShell Module for Extrahop 3 | 4 | ![](https://github.com/hematic/Storage/raw/master/CurrentExtrahopAPICoverage.PNG) 5 | 6 | The image above shows the current API coverage for this module. There may be some minor updates before christmas but for the most part this is in a "finished" state before the holidays. Of course if you find any bugs or want improvements please raise an issue. 7 | 8 | The end goal of this module is to provide total API coverage. I am aware there is amodule out there for Extrahop made by one of the technicians at the company. Its great work, and me choosing to make this is in no way a slight against that work. I needed to make this for two major reasons. 9 | 10 | 1. That module uses classes which are not available for all of my users do to version limitations. 11 | 2. That module has scant documentation and is pretty complicated to use if you arent use to the class sctructure. 12 | 13 | This module is designed to be more "user friendly" with typical powershell function names for each individual API call. 14 | 15 | There is an option for those of you who use self Signed certificates as well. Every command has the flag -AllowselfSignedCert which will allow invoke command to process these calls correctly. 16 | 17 | I hope this helps some other people get comfortable with using Extrahop! -------------------------------------------------------------------------------- /1.0.0/Public/AuditLog.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAuditLog{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop auditlog lines. 5 | .DESCRIPTION 6 | This function allows you to retrieve the Extrahop auditlog lines. 7 | .EXAMPLE 8 | Get-ExtrahopAuditLog -apiKey $Apikey -appliance $appliancename -limit 10 -offset 5 -AllowSelfSignedCert 9 | #> 10 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 11 | Param( 12 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 13 | [String]$apiKey, 14 | 15 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 16 | [String]$appliance, 17 | 18 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 19 | [int]$limit=100, 20 | 21 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 22 | [int]$offset=0, 23 | 24 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 25 | [switch]$AllowSelfSignedCert 26 | ) 27 | 28 | #Set Protocol type to work with Self Signed SSL Cert 29 | If($AllowSelfSignedCert){ 30 | #region Cert 31 | add-type @" 32 | using System.Net; 33 | using System.Security.Cryptography.X509Certificates; 34 | public class TrustAllCertsPolicy : ICertificatePolicy { 35 | public bool CheckValidationResult( 36 | ServicePoint srvPoint, X509Certificate certificate, 37 | WebRequest request, int certificateProblem) { 38 | return true; 39 | } 40 | } 41 | "@ 42 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 43 | #endregion 44 | } 45 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 46 | $Root = "https://" + $appliance + "/api/v1" 47 | $endpoint = "/auditlog" 48 | $URI = $Root + $Endpoint + "?limit=" + $limit + "&offset=" + $offset 49 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 50 | } 51 | -------------------------------------------------------------------------------- /1.0.1/Public/AuditLog.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAuditLog{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop auditlog lines. 5 | .DESCRIPTION 6 | This function allows you to retrieve the Extrahop auditlog lines. 7 | .EXAMPLE 8 | Get-ExtrahopAuditLog -apiKey $Apikey -appliance $appliancename -limit 10 -offset 5 -AllowSelfSignedCert 9 | #> 10 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 11 | Param( 12 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 13 | [String]$apiKey, 14 | 15 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 16 | [String]$appliance, 17 | 18 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 19 | [int]$limit=100, 20 | 21 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 22 | [int]$offset=0, 23 | 24 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 25 | [switch]$AllowSelfSignedCert 26 | ) 27 | 28 | #Set Protocol type to work with Self Signed SSL Cert 29 | If($AllowSelfSignedCert){ 30 | #region Cert 31 | add-type @" 32 | using System.Net; 33 | using System.Security.Cryptography.X509Certificates; 34 | public class TrustAllCertsPolicy : ICertificatePolicy { 35 | public bool CheckValidationResult( 36 | ServicePoint srvPoint, X509Certificate certificate, 37 | WebRequest request, int certificateProblem) { 38 | return true; 39 | } 40 | } 41 | "@ 42 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 43 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 44 | #endregion 45 | } 46 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 47 | $Root = "https://" + $appliance + "/api/v1" 48 | $endpoint = "/auditlog" 49 | $URI = $Root + $Endpoint + "?limit=" + $limit + "&offset=" + $offset 50 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 51 | } 52 | -------------------------------------------------------------------------------- /1.0.0/Public/activitygroups.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopActivityGroups{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop activity groups 5 | .DESCRIPTION 6 | This function allows you to retrieve extrahop activity group and associated dashboards. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopActivityGroups @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apikey 17 | appliance = $appliancename 18 | id = 11 19 | dashboard = $true 20 | allowselfsignedcert = $True 21 | } 22 | Get-ExtrahopActivityGroups @Splat 23 | #> 24 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 25 | Param( 26 | [Parameter(Mandatory=$True)] 27 | [String]$apiKey, 28 | 29 | [Parameter(Mandatory=$True)] 30 | [String]$appliance, 31 | 32 | [Parameter(Mandatory=$false)] 33 | [int]$id, 34 | 35 | [Parameter(Mandatory=$false)] 36 | [switch]$dashboards, 37 | 38 | [Parameter(Mandatory=$false)] 39 | [switch]$AllowSelfSignedCert 40 | ) 41 | 42 | #Set Protocol type to work with Self Signed SSL Cert 43 | If($AllowSelfSignedCert){ 44 | #region Cert 45 | add-type @" 46 | using System.Net; 47 | using System.Security.Cryptography.X509Certificates; 48 | public class TrustAllCertsPolicy : ICertificatePolicy { 49 | public bool CheckValidationResult( 50 | ServicePoint srvPoint, X509Certificate certificate, 51 | WebRequest request, int certificateProblem) { 52 | return true; 53 | } 54 | } 55 | "@ 56 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 57 | #endregion 58 | } 59 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 60 | $Root = "https://" + $appliance + "/api/v1" 61 | $Endpoint = '/activitygroups' 62 | if($id){ 63 | $URI = $Root + $Endpoint + "/" + $id + "/" + "dashboards" 64 | } 65 | else{ 66 | $URI = $Root + $Endpoint 67 | } 68 | $uri 69 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 70 | } -------------------------------------------------------------------------------- /1.0.1/Public/activitygroups.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopActivityGroups{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop activity groups 5 | .DESCRIPTION 6 | This function allows you to retrieve extrahop activity group and associated dashboards. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopActivityGroups @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apikey 17 | appliance = $appliancename 18 | id = 11 19 | dashboard = $true 20 | allowselfsignedcert = $True 21 | } 22 | Get-ExtrahopActivityGroups @Splat 23 | #> 24 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 25 | Param( 26 | [Parameter(Mandatory=$True)] 27 | [String]$apiKey, 28 | 29 | [Parameter(Mandatory=$True)] 30 | [String]$appliance, 31 | 32 | [Parameter(Mandatory=$false)] 33 | [int]$id, 34 | 35 | [Parameter(Mandatory=$false)] 36 | [switch]$dashboards, 37 | 38 | [Parameter(Mandatory=$false)] 39 | [switch]$AllowSelfSignedCert 40 | ) 41 | 42 | #Set Protocol type to work with Self Signed SSL Cert 43 | If($AllowSelfSignedCert){ 44 | #region Cert 45 | add-type @" 46 | using System.Net; 47 | using System.Security.Cryptography.X509Certificates; 48 | public class TrustAllCertsPolicy : ICertificatePolicy { 49 | public bool CheckValidationResult( 50 | ServicePoint srvPoint, X509Certificate certificate, 51 | WebRequest request, int certificateProblem) { 52 | return true; 53 | } 54 | } 55 | "@ 56 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 57 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 58 | #endregion 59 | } 60 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 61 | $Root = "https://" + $appliance + "/api/v1" 62 | $Endpoint = '/activitygroups' 63 | if($id){ 64 | $URI = $Root + $Endpoint + "/" + $id + "/" + "dashboards" 65 | } 66 | else{ 67 | $URI = $Root + $Endpoint 68 | } 69 | $uri 70 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 71 | } -------------------------------------------------------------------------------- /1.0.0/Public/appliance.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAppliance{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop appliances. 5 | .DESCRIPTION 6 | This function allows you to retrieve extrahop appliance information including data on 7 | cloudservices and the product key from the command appliance. 8 | .EXAMPLE 9 | $Splat = @{ 10 | apiKey = $apiKey 11 | appliance = $appliancename 12 | id = 15 13 | allowselfsignedcert = $True 14 | } 15 | Get-ExtrahopAppliance @Splat 16 | .EXAMPLE 17 | $Splat = @{ 18 | apiKey = $apiKey 19 | appliance = $appliancename 20 | id = 15 21 | cloudservices = $true 22 | allowselfsignedcert = $True 23 | } 24 | Get-ExtrahopAppliance @Splat 25 | .EXAMPLE 26 | $Splat = @{ 27 | apiKey = $apiKey 28 | appliance = $appliancename 29 | id = 15 30 | productkey = $true 31 | allowselfsignedcert = $True 32 | } 33 | Get-ExtrahopAppliance @Splat 34 | #> 35 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 36 | Param( 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$apiKey, 39 | 40 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [String]$appliance, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [int]$id, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [switch]$cloudservices, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [switch]$productkey, 51 | 52 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 53 | [switch]$AllowSelfSignedCert 54 | ) 55 | 56 | #Set Protocol type to work with Self Signed SSL Cert 57 | If($AllowSelfSignedCert){ 58 | #region Cert 59 | add-type @" 60 | using System.Net; 61 | using System.Security.Cryptography.X509Certificates; 62 | public class TrustAllCertsPolicy : ICertificatePolicy { 63 | public bool CheckValidationResult( 64 | ServicePoint srvPoint, X509Certificate certificate, 65 | WebRequest request, int certificateProblem) { 66 | return true; 67 | } 68 | } 69 | "@ 70 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 71 | #endregion 72 | } 73 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 74 | $Root = "https://" + $appliance + "/api/v1" 75 | $Endpoint = '/appliances' 76 | If($id){ 77 | If($cloudservices){ 78 | $URI = $Root + $Endpoint + "/" + $id + "/" + "cloudservices" 79 | } 80 | ElseIf($productkey){ 81 | $URI = $Root + $Endpoint + "/" + $id + "/" + "productkey" 82 | } 83 | Else{ 84 | $URI = $Root + $Endpoint + "/" + $id 85 | } 86 | } 87 | Else{ 88 | $URI = $Root + $Endpoint 89 | } 90 | $uri 91 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 92 | } 93 | -------------------------------------------------------------------------------- /1.0.1/Public/appliance.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAppliance{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop appliances. 5 | .DESCRIPTION 6 | This function allows you to retrieve extrahop appliance information including data on 7 | cloudservices and the product key from the command appliance. 8 | .EXAMPLE 9 | $Splat = @{ 10 | apiKey = $apiKey 11 | appliance = $appliancename 12 | id = 15 13 | allowselfsignedcert = $True 14 | } 15 | Get-ExtrahopAppliance @Splat 16 | .EXAMPLE 17 | $Splat = @{ 18 | apiKey = $apiKey 19 | appliance = $appliancename 20 | id = 15 21 | cloudservices = $true 22 | allowselfsignedcert = $True 23 | } 24 | Get-ExtrahopAppliance @Splat 25 | .EXAMPLE 26 | $Splat = @{ 27 | apiKey = $apiKey 28 | appliance = $appliancename 29 | id = 15 30 | productkey = $true 31 | allowselfsignedcert = $True 32 | } 33 | Get-ExtrahopAppliance @Splat 34 | #> 35 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 36 | Param( 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$apiKey, 39 | 40 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [String]$appliance, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [int]$id, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [switch]$cloudservices, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [switch]$productkey, 51 | 52 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 53 | [switch]$AllowSelfSignedCert 54 | ) 55 | 56 | #Set Protocol type to work with Self Signed SSL Cert 57 | If($AllowSelfSignedCert){ 58 | #region Cert 59 | add-type @" 60 | using System.Net; 61 | using System.Security.Cryptography.X509Certificates; 62 | public class TrustAllCertsPolicy : ICertificatePolicy { 63 | public bool CheckValidationResult( 64 | ServicePoint srvPoint, X509Certificate certificate, 65 | WebRequest request, int certificateProblem) { 66 | return true; 67 | } 68 | } 69 | "@ 70 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 71 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 72 | #endregion 73 | } 74 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 75 | $Root = "https://" + $appliance + "/api/v1" 76 | $Endpoint = '/appliances' 77 | If($id){ 78 | If($cloudservices){ 79 | $URI = $Root + $Endpoint + "/" + $id + "/" + "cloudservices" 80 | } 81 | ElseIf($productkey){ 82 | $URI = $Root + $Endpoint + "/" + $id + "/" + "productkey" 83 | } 84 | Else{ 85 | $URI = $Root + $Endpoint + "/" + $id 86 | } 87 | } 88 | Else{ 89 | $URI = $Root + $Endpoint 90 | } 91 | $uri 92 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 93 | } 94 | -------------------------------------------------------------------------------- /1.0.0/Public/triggers.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopTriggers{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop triggers 5 | .DESCRIPTION 6 | This function allows you to retrieve triggers and the devicegroups and devices they are applied to. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopTriggers @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 27 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopTriggers @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | id = 27 27 | devices = $true 28 | allowselfsignedcert = $True 29 | } 30 | Get-ExtrahopTriggers @Splat 31 | .EXAMPLE 32 | $Splat = @{ 33 | apiKey = $apiKey 34 | appliance = $appliancename 35 | id = 27 36 | devicegroups = $true 37 | allowselfsignedcert = $True 38 | } 39 | Get-ExtrahopTriggers @Splat 40 | #> 41 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 42 | Param( 43 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [String]$apiKey, 45 | 46 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [String]$appliance, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [int]$id, 51 | 52 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 53 | [switch]$devicegroups, 54 | 55 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 56 | [switch]$devices, 57 | 58 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 59 | [switch]$AllowSelfSignedCert 60 | ) 61 | 62 | #Set Protocol type to work with Self Signed SSL Cert 63 | If($AllowSelfSignedCert){ 64 | #region Cert 65 | add-type @" 66 | using System.Net; 67 | using System.Security.Cryptography.X509Certificates; 68 | public class TrustAllCertsPolicy : ICertificatePolicy { 69 | public bool CheckValidationResult( 70 | ServicePoint srvPoint, X509Certificate certificate, 71 | WebRequest request, int certificateProblem) { 72 | return true; 73 | } 74 | } 75 | "@ 76 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 77 | #endregion 78 | } 79 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 80 | $Root = "https://" + $appliance + "/api/v1" 81 | $Endpoint = '/triggers' 82 | if($id){ 83 | If($devicegroups){ 84 | $URI = $Root + $Endpoint + "/" + $id + "/" + "devicegroups" 85 | } 86 | ElseIf($devices){ 87 | $URI = $Root + $Endpoint + "/" + $id + "/" + "devices" 88 | } 89 | Else{ 90 | $URI = $Root + $Endpoint + "/" + $id 91 | } 92 | } 93 | else{ 94 | $URI = $Root + $Endpoint 95 | } 96 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 97 | } 98 | -------------------------------------------------------------------------------- /1.0.1/Public/triggers.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopTriggers{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop triggers 5 | .DESCRIPTION 6 | This function allows you to retrieve triggers and the devicegroups and devices they are applied to. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopTriggers @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 27 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopTriggers @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | id = 27 27 | devices = $true 28 | allowselfsignedcert = $True 29 | } 30 | Get-ExtrahopTriggers @Splat 31 | .EXAMPLE 32 | $Splat = @{ 33 | apiKey = $apiKey 34 | appliance = $appliancename 35 | id = 27 36 | devicegroups = $true 37 | allowselfsignedcert = $True 38 | } 39 | Get-ExtrahopTriggers @Splat 40 | #> 41 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 42 | Param( 43 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [String]$apiKey, 45 | 46 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [String]$appliance, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [int]$id, 51 | 52 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 53 | [switch]$devicegroups, 54 | 55 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 56 | [switch]$devices, 57 | 58 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 59 | [switch]$AllowSelfSignedCert 60 | ) 61 | 62 | #Set Protocol type to work with Self Signed SSL Cert 63 | If($AllowSelfSignedCert){ 64 | #region Cert 65 | add-type @" 66 | using System.Net; 67 | using System.Security.Cryptography.X509Certificates; 68 | public class TrustAllCertsPolicy : ICertificatePolicy { 69 | public bool CheckValidationResult( 70 | ServicePoint srvPoint, X509Certificate certificate, 71 | WebRequest request, int certificateProblem) { 72 | return true; 73 | } 74 | } 75 | "@ 76 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 77 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 78 | #endregion 79 | } 80 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 81 | $Root = "https://" + $appliance + "/api/v1" 82 | $Endpoint = '/triggers' 83 | if($id){ 84 | If($devicegroups){ 85 | $URI = $Root + $Endpoint + "/" + $id + "/" + "devicegroups" 86 | } 87 | ElseIf($devices){ 88 | $URI = $Root + $Endpoint + "/" + $id + "/" + "devices" 89 | } 90 | Else{ 91 | $URI = $Root + $Endpoint + "/" + $id 92 | } 93 | } 94 | else{ 95 | $URI = $Root + $Endpoint 96 | } 97 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 98 | } 99 | -------------------------------------------------------------------------------- /1.0.0/Public/PacketCapture.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopPacketCapture{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop packet captures. 5 | .DESCRIPTION 6 | This function allows you to retrieve Extrahop packet captures. 7 | .EXAMPLE 8 | Get-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename 9 | .EXAMPLE 10 | Get-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [String]$id, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [switch]$AllowSelfSignedCert 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 42 | #endregion 43 | } 44 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 45 | $Root = "https://" + $appliance + "/api/v1" 46 | $endpoint = "/packetcaptures" 47 | If($id){ 48 | $URI = $Root + $Endpoint + "/" + $id 49 | } 50 | Else{ 51 | $URI = $Root + $Endpoint 52 | } 53 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 54 | } 55 | 56 | Function Remove-ExtrahopPacketCapture{ 57 | <# 58 | .SYNOPSIS 59 | Function to delete Extrahop PacketCapture. 60 | .DESCRIPTION 61 | This function allows you to delete Extrahop PacketCaptures. 62 | .EXAMPLE 63 | Remove-ExtrahopPacketCapture -apiKey $Apikey -appliance -id 99 $appliancename 64 | .EXAMPLE 65 | Remove-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename -id 99 -childID 45 -AllowSelfSignedCert 66 | #> 67 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 68 | Param( 69 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 70 | [String]$apiKey, 71 | 72 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 73 | [String]$appliance, 74 | 75 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 76 | [String]$id, 77 | 78 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 79 | [switch]$AllowSelfSignedCert 80 | ) 81 | 82 | #Set Protocol type to work with Self Signed SSL Cert 83 | If($AllowSelfSignedCert){ 84 | #region Cert 85 | add-type @" 86 | using System.Net; 87 | using System.Security.Cryptography.X509Certificates; 88 | public class TrustAllCertsPolicy : ICertificatePolicy { 89 | public bool CheckValidationResult( 90 | ServicePoint srvPoint, X509Certificate certificate, 91 | WebRequest request, int certificateProblem) { 92 | return true; 93 | } 94 | } 95 | "@ 96 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 97 | #endregion 98 | } 99 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 100 | $Root = "https://" + $appliance + "/api/v1" 101 | $endpoint = "/packetcaptures" 102 | $URI = $Root + $Endpoint + "/" + $id 103 | 104 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 105 | } -------------------------------------------------------------------------------- /1.0.0/Public/apikeys.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAPIKeys{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop apiKeys. 5 | .DESCRIPTION 6 | This function allows you to retrieve either all apiKeys or one by ID. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopAPIKeys @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 1 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopAPIKeys @Splat 22 | #> 23 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 24 | Param( 25 | [Parameter(Mandatory=$True)] 26 | [String]$apiKey, 27 | 28 | [Parameter(Mandatory=$True)] 29 | [String]$appliance, 30 | 31 | [Parameter(Mandatory=$false)] 32 | [int]$id, 33 | 34 | [Parameter(Mandatory=$false)] 35 | [switch]$AllowSelfSignedCert 36 | ) 37 | 38 | #Set Protocol type to work with Self Signed SSL Cert 39 | If($AllowSelfSignedCert){ 40 | #region Cert 41 | add-type @" 42 | using System.Net; 43 | using System.Security.Cryptography.X509Certificates; 44 | public class TrustAllCertsPolicy : ICertificatePolicy { 45 | public bool CheckValidationResult( 46 | ServicePoint srvPoint, X509Certificate certificate, 47 | WebRequest request, int certificateProblem) { 48 | return true; 49 | } 50 | } 51 | "@ 52 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 53 | #endregion 54 | } 55 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 56 | $Root = "https://" + $appliance + "/api/v1" 57 | $Endpoint = '/apikeys' 58 | If($id){ 59 | $URI = $Root + $Endpoint + "/" + $id 60 | } 61 | Else{ 62 | $URI = $Root + $Endpoint 63 | } 64 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 65 | } 66 | 67 | Function New-ExtrahopAPIKey{ 68 | <# 69 | .SYNOPSIS 70 | Function to create Extrahop apiKeys 71 | .DESCRIPTION 72 | This function allows you to create new apiKeys but only for the setup user. 73 | .EXAMPLE 74 | $Splat = @{ 75 | apiKey = $apiKey 76 | appliance = $appliancename 77 | setuppassword = 'am1' 78 | allowselfsignedcert = $True 79 | } 80 | New-ExtrahopAPIKey @Splat 81 | #> 82 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 83 | Param( 84 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 85 | [String]$apiKey, 86 | 87 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 88 | [String]$appliance, 89 | 90 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 91 | [string]$setuppassword, 92 | 93 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 94 | [switch]$AllowSelfSignedCert 95 | ) 96 | 97 | #Set Protocol type to work with Self Signed SSL Cert 98 | If($AllowSelfSignedCert){ 99 | #region Cert 100 | add-type @" 101 | using System.Net; 102 | using System.Security.Cryptography.X509Certificates; 103 | public class TrustAllCertsPolicy : ICertificatePolicy { 104 | public bool CheckValidationResult( 105 | ServicePoint srvPoint, X509Certificate certificate, 106 | WebRequest request, int certificateProblem) { 107 | return true; 108 | } 109 | } 110 | "@ 111 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 112 | #endregion 113 | } 114 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 115 | $Root = "https://" + $appliance + "/api/v1" 116 | $Endpoint = '/apikeys' 117 | $URI = $Root + $Endpoint 118 | #region body 119 | $body = @" 120 | { 121 | "password": "$setuppassword" 122 | } 123 | "@ 124 | #endregion 125 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 126 | } -------------------------------------------------------------------------------- /1.0.1/Public/PacketCapture.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopPacketCapture{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop packet captures. 5 | .DESCRIPTION 6 | This function allows you to retrieve Extrahop packet captures. 7 | .EXAMPLE 8 | Get-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename 9 | .EXAMPLE 10 | Get-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [String]$id, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [switch]$AllowSelfSignedCert 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 42 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 43 | #endregion 44 | } 45 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 46 | $Root = "https://" + $appliance + "/api/v1" 47 | $endpoint = "/packetcaptures" 48 | If($id){ 49 | $URI = $Root + $Endpoint + "/" + $id 50 | } 51 | Else{ 52 | $URI = $Root + $Endpoint 53 | } 54 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 55 | } 56 | 57 | Function Remove-ExtrahopPacketCapture{ 58 | <# 59 | .SYNOPSIS 60 | Function to delete Extrahop PacketCapture. 61 | .DESCRIPTION 62 | This function allows you to delete Extrahop PacketCaptures. 63 | .EXAMPLE 64 | Remove-ExtrahopPacketCapture -apiKey $Apikey -appliance -id 99 $appliancename 65 | .EXAMPLE 66 | Remove-ExtrahopPacketCapture -apiKey $Apikey -appliance $appliancename -id 99 -childID 45 -AllowSelfSignedCert 67 | #> 68 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 69 | Param( 70 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 71 | [String]$apiKey, 72 | 73 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 74 | [String]$appliance, 75 | 76 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 77 | [String]$id, 78 | 79 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 80 | [switch]$AllowSelfSignedCert 81 | ) 82 | 83 | #Set Protocol type to work with Self Signed SSL Cert 84 | If($AllowSelfSignedCert){ 85 | #region Cert 86 | add-type @" 87 | using System.Net; 88 | using System.Security.Cryptography.X509Certificates; 89 | public class TrustAllCertsPolicy : ICertificatePolicy { 90 | public bool CheckValidationResult( 91 | ServicePoint srvPoint, X509Certificate certificate, 92 | WebRequest request, int certificateProblem) { 93 | return true; 94 | } 95 | } 96 | "@ 97 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 98 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 99 | #endregion 100 | } 101 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 102 | $Root = "https://" + $appliance + "/api/v1" 103 | $endpoint = "/packetcaptures" 104 | $URI = $Root + $Endpoint + "/" + $id 105 | 106 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 107 | } -------------------------------------------------------------------------------- /1.0.1/Public/apikeys.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopAPIKeys{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop apiKeys. 5 | .DESCRIPTION 6 | This function allows you to retrieve either all apiKeys or one by ID. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopAPIKeys @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 1 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopAPIKeys @Splat 22 | #> 23 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 24 | Param( 25 | [Parameter(Mandatory=$True)] 26 | [String]$apiKey, 27 | 28 | [Parameter(Mandatory=$True)] 29 | [String]$appliance, 30 | 31 | [Parameter(Mandatory=$false)] 32 | [int]$id, 33 | 34 | [Parameter(Mandatory=$false)] 35 | [switch]$AllowSelfSignedCert 36 | ) 37 | 38 | #Set Protocol type to work with Self Signed SSL Cert 39 | If($AllowSelfSignedCert){ 40 | #region Cert 41 | add-type @" 42 | using System.Net; 43 | using System.Security.Cryptography.X509Certificates; 44 | public class TrustAllCertsPolicy : ICertificatePolicy { 45 | public bool CheckValidationResult( 46 | ServicePoint srvPoint, X509Certificate certificate, 47 | WebRequest request, int certificateProblem) { 48 | return true; 49 | } 50 | } 51 | "@ 52 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 53 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 54 | #endregion 55 | } 56 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 57 | $Root = "https://" + $appliance + "/api/v1" 58 | $Endpoint = '/apikeys' 59 | If($id){ 60 | $URI = $Root + $Endpoint + "/" + $id 61 | } 62 | Else{ 63 | $URI = $Root + $Endpoint 64 | } 65 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 66 | } 67 | 68 | Function New-ExtrahopAPIKey{ 69 | <# 70 | .SYNOPSIS 71 | Function to create Extrahop apiKeys 72 | .DESCRIPTION 73 | This function allows you to create new apiKeys but only for the setup user. 74 | .EXAMPLE 75 | $Splat = @{ 76 | apiKey = $apiKey 77 | appliance = $appliancename 78 | setuppassword = 'am1' 79 | allowselfsignedcert = $True 80 | } 81 | New-ExtrahopAPIKey @Splat 82 | #> 83 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 84 | Param( 85 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 86 | [String]$apiKey, 87 | 88 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 89 | [String]$appliance, 90 | 91 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 92 | [string]$setuppassword, 93 | 94 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 95 | [switch]$AllowSelfSignedCert 96 | ) 97 | 98 | #Set Protocol type to work with Self Signed SSL Cert 99 | If($AllowSelfSignedCert){ 100 | #region Cert 101 | add-type @" 102 | using System.Net; 103 | using System.Security.Cryptography.X509Certificates; 104 | public class TrustAllCertsPolicy : ICertificatePolicy { 105 | public bool CheckValidationResult( 106 | ServicePoint srvPoint, X509Certificate certificate, 107 | WebRequest request, int certificateProblem) { 108 | return true; 109 | } 110 | } 111 | "@ 112 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 113 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 114 | #endregion 115 | } 116 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 117 | $Root = "https://" + $appliance + "/api/v1" 118 | $Endpoint = '/apikeys' 119 | $URI = $Root + $Endpoint 120 | #region body 121 | $body = @" 122 | { 123 | "password": "$setuppassword" 124 | } 125 | "@ 126 | #endregion 127 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 128 | } -------------------------------------------------------------------------------- /1.0.0/Public/Detections.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopDetections{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop detections. 5 | .DESCRIPTION 6 | This function allows you to retrieve all detections or one by ID 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | id = '15' 12 | allowselfsignedcert = $True 13 | } 14 | Get-ExtrahopDetections @Splat 15 | .EXAMPLE 16 | $Splat = @{ 17 | apiKey = $apikey 18 | appliance = $appliancename 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopDetections @Splat 22 | #> 23 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 24 | Param( 25 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 26 | [String]$apiKey, 27 | 28 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 29 | [String]$appliance, 30 | 31 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 32 | [string]$id, 33 | 34 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 35 | [switch]$AllowSelfSignedCert 36 | ) 37 | 38 | #Set Protocol type to work with Self Signed SSL Cert 39 | If($AllowSelfSignedCert){ 40 | #region Cert 41 | add-type @" 42 | using System.Net; 43 | using System.Security.Cryptography.X509Certificates; 44 | public class TrustAllCertsPolicy : ICertificatePolicy { 45 | public bool CheckValidationResult( 46 | ServicePoint srvPoint, X509Certificate certificate, 47 | WebRequest request, int certificateProblem) { 48 | return true; 49 | } 50 | } 51 | "@ 52 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 53 | #endregion 54 | } 55 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 56 | $Root = "https://" + $appliance + "/api/v1" 57 | $Endpoint = '/detections' 58 | If($id){ 59 | $URI = $Root + $Endpoint + "/" + $id 60 | } 61 | Else{ 62 | $URI = $Root + $Endpoint 63 | } 64 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 65 | } 66 | 67 | Function Update-ExtrahopDetection{ 68 | <# 69 | .SYNOPSIS 70 | Function to update data for an Extrahop detection. 71 | .DESCRIPTION 72 | This function allows you to edit the description, field, name, value 73 | and include_custom_devices properties for a devicegroup. 74 | .EXAMPLE 75 | $Splat = @{ 76 | apiKey = $apiKey 77 | appliance = $appliancename 78 | id = 77 79 | assignee = 'tag' 80 | resolution = 'action_taken' 81 | status = 'new' 82 | ticket_id = '8675309' 83 | } 84 | Update-ExtrahopDetection @Splat 85 | #> 86 | Param( 87 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 88 | [String]$apiKey, 89 | 90 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 91 | [String]$appliance, 92 | 93 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 94 | [string]$id, 95 | 96 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 97 | [string]$assignee, 98 | 99 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 100 | [ValidateSet('action_taken','no_action_taken')] 101 | [string]$resolution, 102 | 103 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 104 | [ValidateSet('new','in_progress','closed')] 105 | [string]$status, 106 | 107 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 108 | [string]$ticket_id, 109 | 110 | [Parameter(Mandatory=$false)] 111 | [switch]$AllowSelfSignedCert 112 | ) 113 | 114 | #Set Protocol type to work with Self Signed SSL Cert 115 | If($AllowSelfSignedCert){ 116 | #region Cert 117 | add-type @" 118 | using System.Net; 119 | using System.Security.Cryptography.X509Certificates; 120 | public class TrustAllCertsPolicy : ICertificatePolicy { 121 | public bool CheckValidationResult( 122 | ServicePoint srvPoint, X509Certificate certificate, 123 | WebRequest request, int certificateProblem) { 124 | return true; 125 | } 126 | } 127 | "@ 128 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 129 | #endregion 130 | } 131 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 132 | $Root = "https://" + $appliance + "/api/v1" 133 | 134 | $Body = @{} 135 | $bodyParams = @('assignee','resolution','status','ticket_id') 136 | Foreach($Item in $PSBoundParameters.keys | where-object {$_ -in $bodyParams}){ 137 | $Body.$Item = $PSBoundParameters.Item($Item) 138 | } 139 | $jsonbody = ConvertTo-Json $Body 140 | $Endpoint = '/devicegroups' 141 | $URI = $Root + $Endpoint + "/" + $id 142 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $jsonbody -ErrorAction Stop 143 | } -------------------------------------------------------------------------------- /1.0.1/Public/Detections.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopDetections{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop detections. 5 | .DESCRIPTION 6 | This function allows you to retrieve all detections or one by ID 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | id = '15' 12 | allowselfsignedcert = $True 13 | } 14 | Get-ExtrahopDetections @Splat 15 | .EXAMPLE 16 | $Splat = @{ 17 | apiKey = $apikey 18 | appliance = $appliancename 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopDetections @Splat 22 | #> 23 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 24 | Param( 25 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 26 | [String]$apiKey, 27 | 28 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 29 | [String]$appliance, 30 | 31 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 32 | [string]$id, 33 | 34 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 35 | [switch]$AllowSelfSignedCert 36 | ) 37 | 38 | #Set Protocol type to work with Self Signed SSL Cert 39 | If($AllowSelfSignedCert){ 40 | #region Cert 41 | add-type @" 42 | using System.Net; 43 | using System.Security.Cryptography.X509Certificates; 44 | public class TrustAllCertsPolicy : ICertificatePolicy { 45 | public bool CheckValidationResult( 46 | ServicePoint srvPoint, X509Certificate certificate, 47 | WebRequest request, int certificateProblem) { 48 | return true; 49 | } 50 | } 51 | "@ 52 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 53 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 54 | #endregion 55 | } 56 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 57 | $Root = "https://" + $appliance + "/api/v1" 58 | $Endpoint = '/detections' 59 | If($id){ 60 | $URI = $Root + $Endpoint + "/" + $id 61 | } 62 | Else{ 63 | $URI = $Root + $Endpoint 64 | } 65 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 66 | } 67 | 68 | Function Update-ExtrahopDetection{ 69 | <# 70 | .SYNOPSIS 71 | Function to update data for an Extrahop detection. 72 | .DESCRIPTION 73 | This function allows you to edit the description, field, name, value 74 | and include_custom_devices properties for a devicegroup. 75 | .EXAMPLE 76 | $Splat = @{ 77 | apiKey = $apiKey 78 | appliance = $appliancename 79 | id = 77 80 | assignee = 'tag' 81 | resolution = 'action_taken' 82 | status = 'new' 83 | ticket_id = '8675309' 84 | } 85 | Update-ExtrahopDetection @Splat 86 | #> 87 | Param( 88 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 89 | [String]$apiKey, 90 | 91 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 92 | [String]$appliance, 93 | 94 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 95 | [string]$id, 96 | 97 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 98 | [string]$assignee, 99 | 100 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 101 | [ValidateSet('action_taken','no_action_taken')] 102 | [string]$resolution, 103 | 104 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 105 | [ValidateSet('new','in_progress','closed')] 106 | [string]$status, 107 | 108 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 109 | [string]$ticket_id, 110 | 111 | [Parameter(Mandatory=$false)] 112 | [switch]$AllowSelfSignedCert 113 | ) 114 | 115 | #Set Protocol type to work with Self Signed SSL Cert 116 | If($AllowSelfSignedCert){ 117 | #region Cert 118 | add-type @" 119 | using System.Net; 120 | using System.Security.Cryptography.X509Certificates; 121 | public class TrustAllCertsPolicy : ICertificatePolicy { 122 | public bool CheckValidationResult( 123 | ServicePoint srvPoint, X509Certificate certificate, 124 | WebRequest request, int certificateProblem) { 125 | return true; 126 | } 127 | } 128 | "@ 129 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 130 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 131 | #endregion 132 | } 133 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 134 | $Root = "https://" + $appliance + "/api/v1" 135 | 136 | $Body = @{} 137 | $bodyParams = @('assignee','resolution','status','ticket_id') 138 | Foreach($Item in $PSBoundParameters.keys | where-object {$_ -in $bodyParams}){ 139 | $Body.$Item = $PSBoundParameters.Item($Item) 140 | } 141 | $jsonbody = ConvertTo-Json $Body 142 | $Endpoint = '/devicegroups' 143 | $URI = $Root + $Endpoint + "/" + $id 144 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $jsonbody -ErrorAction Stop 145 | } -------------------------------------------------------------------------------- /1.0.0/Public/nodes.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopNodes{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Nodes 5 | .DESCRIPTION 6 | This function allows you to retrieve all nodes or a specific node. 7 | .EXAMPLE 8 | Get-ExtrahopNodes -apiKey $apikey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopNodes -apiKey $apiKey -appliance 'Command Appliance' -node 11 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 13 | Param( 14 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 15 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 16 | [String]$apiKey, 17 | 18 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 19 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 20 | [String]$appliance, 21 | 22 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 23 | [switch]$AllowSelfSignedCert, 24 | 25 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 26 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 27 | [int]$node 28 | ) 29 | 30 | #Set Protocol type to work with Self Signed SSL Cert 31 | If($AllowSelfSignedCert){ 32 | #region Cert 33 | add-type @" 34 | using System.Net; 35 | using System.Security.Cryptography.X509Certificates; 36 | public class TrustAllCertsPolicy : ICertificatePolicy { 37 | public bool CheckValidationResult( 38 | ServicePoint srvPoint, X509Certificate certificate, 39 | WebRequest request, int certificateProblem) { 40 | return true; 41 | } 42 | } 43 | "@ 44 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 45 | #endregion 46 | } 47 | $Endpoint = '/nodes' 48 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 49 | $Root = "https://" + $appliance + "/api/v1" 50 | #region Build URI 51 | switch ($PsCmdlet.ParameterSetName) 52 | { 53 | 'All' { 54 | $URI = $Root + $Endpoint 55 | } 56 | 57 | 'ByID' { 58 | $URI = $Root + $Endpoint + '/' + $ID 59 | } 60 | } 61 | 62 | #endregion 63 | $results = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 64 | Return $results 65 | } 66 | Function Update-ExtrahopNode{ 67 | <# 68 | .SYNOPSIS 69 | Function to update an Extrahop node. 70 | .DESCRIPTION 71 | This function allows you to update the friendly name or enabled status of 72 | a specific node. 73 | .EXAMPLE 74 | Update-ExtrahopNode -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" 75 | #> 76 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='Description')] 77 | Param( 78 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 79 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 80 | [String]$apiKey, 81 | 82 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 83 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 84 | [String]$appliance, 85 | 86 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 87 | [switch]$AllowSelfSignedCert, 88 | 89 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 90 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 91 | [string]$id, 92 | 93 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 94 | [Parameter(Mandatory=$false,ParameterSetName = 'FriendlyName')] 95 | [string]$description, 96 | 97 | [Parameter(Mandatory=$false,ParameterSetName = 'Description')] 98 | [Parameter(Mandatory=$true,ParameterSetName = 'FriendlyName')] 99 | [string]$name 100 | ) 101 | 102 | #Set Protocol type to work with Self Signed SSL Cert 103 | If($AllowSelfSignedCert){ 104 | #region Cert 105 | add-type @" 106 | using System.Net; 107 | using System.Security.Cryptography.X509Certificates; 108 | public class TrustAllCertsPolicy : ICertificatePolicy { 109 | public bool CheckValidationResult( 110 | ServicePoint srvPoint, X509Certificate certificate, 111 | WebRequest request, int certificateProblem) { 112 | return true; 113 | } 114 | } 115 | "@ 116 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 117 | #endregion 118 | } 119 | $Endpoint = '/vlans' 120 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 121 | $Root = "https://" + $appliance + "/api/v1" 122 | $URI = $Root + $Endpoint + "/" + $id 123 | switch ($PsCmdlet.ParameterSetName){ 124 | 'Description' { 125 | If($friendlyname){ 126 | #region Body 127 | $Body = @" 128 | { 129 | "description" : $description, 130 | "name" : $name 131 | } 132 | "@ 133 | #endregion 134 | } 135 | Else{ 136 | #region Body 137 | $Body = @" 138 | { 139 | "description" : $description 140 | } 141 | "@ 142 | #endregion 143 | } 144 | } 145 | 146 | 'FriendlyName' { 147 | If($description){ 148 | #region Body 149 | $Body = @" 150 | { 151 | "description" : $description, 152 | "name" : $name 153 | } 154 | "@ 155 | #endregion 156 | } 157 | Else{ 158 | #region Body 159 | $Body = @" 160 | { 161 | "name" : $name 162 | } 163 | "@ 164 | #endregion 165 | } 166 | } 167 | } 168 | Write-Host "Retrieving vLan {$id} from $appliance @ $Uri" 169 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 170 | } -------------------------------------------------------------------------------- /1.0.1/Public/nodes.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopNodes{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Nodes 5 | .DESCRIPTION 6 | This function allows you to retrieve all nodes or a specific node. 7 | .EXAMPLE 8 | Get-ExtrahopNodes -apiKey $apikey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopNodes -apiKey $apiKey -appliance 'Command Appliance' -node 11 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 13 | Param( 14 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 15 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 16 | [String]$apiKey, 17 | 18 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 19 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 20 | [String]$appliance, 21 | 22 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 23 | [switch]$AllowSelfSignedCert, 24 | 25 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 26 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 27 | [int]$node 28 | ) 29 | 30 | #Set Protocol type to work with Self Signed SSL Cert 31 | If($AllowSelfSignedCert){ 32 | #region Cert 33 | add-type @" 34 | using System.Net; 35 | using System.Security.Cryptography.X509Certificates; 36 | public class TrustAllCertsPolicy : ICertificatePolicy { 37 | public bool CheckValidationResult( 38 | ServicePoint srvPoint, X509Certificate certificate, 39 | WebRequest request, int certificateProblem) { 40 | return true; 41 | } 42 | } 43 | "@ 44 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 45 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 46 | #endregion 47 | } 48 | $Endpoint = '/nodes' 49 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 50 | $Root = "https://" + $appliance + "/api/v1" 51 | #region Build URI 52 | switch ($PsCmdlet.ParameterSetName) 53 | { 54 | 'All' { 55 | $URI = $Root + $Endpoint 56 | } 57 | 58 | 'ByID' { 59 | $URI = $Root + $Endpoint + '/' + $ID 60 | } 61 | } 62 | 63 | #endregion 64 | $results = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 65 | Return $results 66 | } 67 | Function Update-ExtrahopNode{ 68 | <# 69 | .SYNOPSIS 70 | Function to update an Extrahop node. 71 | .DESCRIPTION 72 | This function allows you to update the friendly name or enabled status of 73 | a specific node. 74 | .EXAMPLE 75 | Update-ExtrahopNode -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" 76 | #> 77 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='Description')] 78 | Param( 79 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 80 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 81 | [String]$apiKey, 82 | 83 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 84 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 85 | [String]$appliance, 86 | 87 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 88 | [switch]$AllowSelfSignedCert, 89 | 90 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 91 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 92 | [string]$id, 93 | 94 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 95 | [Parameter(Mandatory=$false,ParameterSetName = 'FriendlyName')] 96 | [string]$description, 97 | 98 | [Parameter(Mandatory=$false,ParameterSetName = 'Description')] 99 | [Parameter(Mandatory=$true,ParameterSetName = 'FriendlyName')] 100 | [string]$name 101 | ) 102 | 103 | #Set Protocol type to work with Self Signed SSL Cert 104 | If($AllowSelfSignedCert){ 105 | #region Cert 106 | add-type @" 107 | using System.Net; 108 | using System.Security.Cryptography.X509Certificates; 109 | public class TrustAllCertsPolicy : ICertificatePolicy { 110 | public bool CheckValidationResult( 111 | ServicePoint srvPoint, X509Certificate certificate, 112 | WebRequest request, int certificateProblem) { 113 | return true; 114 | } 115 | } 116 | "@ 117 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 118 | #endregion 119 | } 120 | $Endpoint = '/vlans' 121 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 122 | $Root = "https://" + $appliance + "/api/v1" 123 | $URI = $Root + $Endpoint + "/" + $id 124 | switch ($PsCmdlet.ParameterSetName){ 125 | 'Description' { 126 | If($friendlyname){ 127 | #region Body 128 | $Body = @" 129 | { 130 | "description" : $description, 131 | "name" : $name 132 | } 133 | "@ 134 | #endregion 135 | } 136 | Else{ 137 | #region Body 138 | $Body = @" 139 | { 140 | "description" : $description 141 | } 142 | "@ 143 | #endregion 144 | } 145 | } 146 | 147 | 'FriendlyName' { 148 | If($description){ 149 | #region Body 150 | $Body = @" 151 | { 152 | "description" : $description, 153 | "name" : $name 154 | } 155 | "@ 156 | #endregion 157 | } 158 | Else{ 159 | #region Body 160 | $Body = @" 161 | { 162 | "name" : $name 163 | } 164 | "@ 165 | #endregion 166 | } 167 | } 168 | } 169 | Write-Host "Retrieving vLan {$id} from $appliance @ $Uri" 170 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 171 | } -------------------------------------------------------------------------------- /1.0.0/Public/Whitelists.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopWhitelistDevices{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Whitelist 5 | .DESCRIPTION 6 | This function allows you to retrieve all whitelist devices. 7 | .EXAMPLE 8 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [switch]$AllowSelfSignedCert 22 | ) 23 | 24 | #Set Protocol type to work with Self Signed SSL Cert 25 | If($AllowSelfSignedCert){ 26 | #region Cert 27 | add-type @" 28 | using System.Net; 29 | using System.Security.Cryptography.X509Certificates; 30 | public class TrustAllCertsPolicy : ICertificatePolicy { 31 | public bool CheckValidationResult( 32 | ServicePoint srvPoint, X509Certificate certificate, 33 | WebRequest request, int certificateProblem) { 34 | return true; 35 | } 36 | } 37 | "@ 38 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 39 | #endregion 40 | } 41 | $Endpoint = '/whitelist/devices' 42 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 43 | $Root = "https://" + $appliance + "/api/v1" 44 | $URI = $Root + $Endpoint 45 | $Devices = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 46 | Return $Devices 47 | } 48 | 49 | Function Add-ExtrahopWhitelistDevices{ 50 | <# 51 | .SYNOPSIS 52 | Function to add a device to an Extrahop Whitelist 53 | .DESCRIPTION 54 | This function allows you to add a device to a whitelist. 55 | .EXAMPLE 56 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 57 | .EXAMPLE 58 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 59 | #> 60 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 61 | Param( 62 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 63 | [String]$apiKey, 64 | 65 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 66 | [String]$appliance, 67 | 68 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 69 | [switch]$AllowSelfSignedCert, 70 | 71 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 72 | [int]$id 73 | ) 74 | 75 | #Set Protocol type to work with Self Signed SSL Cert 76 | If($AllowSelfSignedCert){ 77 | #region Cert 78 | add-type @" 79 | using System.Net; 80 | using System.Security.Cryptography.X509Certificates; 81 | public class TrustAllCertsPolicy : ICertificatePolicy { 82 | public bool CheckValidationResult( 83 | ServicePoint srvPoint, X509Certificate certificate, 84 | WebRequest request, int certificateProblem) { 85 | return true; 86 | } 87 | } 88 | "@ 89 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 90 | #endregion 91 | } 92 | $Endpoint = '/whitelist/devices' 93 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 94 | $Root = "https://" + $appliance + "/api/v1" 95 | $URI = $Root + $Endpoint + "/" + $id 96 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 97 | } 98 | 99 | Function Remove-ExtrahopWhitelistDevices{ 100 | <# 101 | .SYNOPSIS 102 | Function to remove a device from an Extrahop Whitelist 103 | .DESCRIPTION 104 | This function allows you to remove a device from a whitelist. 105 | .EXAMPLE 106 | Remove-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 107 | .EXAMPLE 108 | Remove-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 109 | #> 110 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 111 | Param( 112 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 113 | [String]$apiKey, 114 | 115 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 116 | [String]$appliance, 117 | 118 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 119 | [switch]$AllowSelfSignedCert, 120 | 121 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 122 | [int]$id 123 | ) 124 | 125 | #Set Protocol type to work with Self Signed SSL Cert 126 | If($AllowSelfSignedCert){ 127 | #region Cert 128 | add-type @" 129 | using System.Net; 130 | using System.Security.Cryptography.X509Certificates; 131 | public class TrustAllCertsPolicy : ICertificatePolicy { 132 | public bool CheckValidationResult( 133 | ServicePoint srvPoint, X509Certificate certificate, 134 | WebRequest request, int certificateProblem) { 135 | return true; 136 | } 137 | } 138 | "@ 139 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 140 | #endregion 141 | } 142 | $Endpoint = '/whitelist/devices' 143 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 144 | $Root = "https://" + $appliance + "/api/v1" 145 | $URI = $Root + $Endpoint + "/" + $id 146 | Invoke-RestMethod -Method 'Remove' -Uri $uri -Headers $headers -ErrorAction Stop 147 | } -------------------------------------------------------------------------------- /1.0.1/Public/Whitelists.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopWhitelistDevices{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Whitelist 5 | .DESCRIPTION 6 | This function allows you to retrieve all whitelist devices. 7 | .EXAMPLE 8 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [switch]$AllowSelfSignedCert 22 | ) 23 | 24 | #Set Protocol type to work with Self Signed SSL Cert 25 | If($AllowSelfSignedCert){ 26 | #region Cert 27 | add-type @" 28 | using System.Net; 29 | using System.Security.Cryptography.X509Certificates; 30 | public class TrustAllCertsPolicy : ICertificatePolicy { 31 | public bool CheckValidationResult( 32 | ServicePoint srvPoint, X509Certificate certificate, 33 | WebRequest request, int certificateProblem) { 34 | return true; 35 | } 36 | } 37 | "@ 38 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 39 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 40 | #endregion 41 | } 42 | $Endpoint = '/whitelist/devices' 43 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 44 | $Root = "https://" + $appliance + "/api/v1" 45 | $URI = $Root + $Endpoint 46 | $Devices = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 47 | Return $Devices 48 | } 49 | 50 | Function Add-ExtrahopWhitelistDevices{ 51 | <# 52 | .SYNOPSIS 53 | Function to add a device to an Extrahop Whitelist 54 | .DESCRIPTION 55 | This function allows you to add a device to a whitelist. 56 | .EXAMPLE 57 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 58 | .EXAMPLE 59 | Get-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 60 | #> 61 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 62 | Param( 63 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 64 | [String]$apiKey, 65 | 66 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 67 | [String]$appliance, 68 | 69 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 70 | [switch]$AllowSelfSignedCert, 71 | 72 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 73 | [int]$id 74 | ) 75 | 76 | #Set Protocol type to work with Self Signed SSL Cert 77 | If($AllowSelfSignedCert){ 78 | #region Cert 79 | add-type @" 80 | using System.Net; 81 | using System.Security.Cryptography.X509Certificates; 82 | public class TrustAllCertsPolicy : ICertificatePolicy { 83 | public bool CheckValidationResult( 84 | ServicePoint srvPoint, X509Certificate certificate, 85 | WebRequest request, int certificateProblem) { 86 | return true; 87 | } 88 | } 89 | "@ 90 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 91 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 92 | #endregion 93 | } 94 | $Endpoint = '/whitelist/devices' 95 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 96 | $Root = "https://" + $appliance + "/api/v1" 97 | $URI = $Root + $Endpoint + "/" + $id 98 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 99 | } 100 | 101 | Function Remove-ExtrahopWhitelistDevices{ 102 | <# 103 | .SYNOPSIS 104 | Function to remove a device from an Extrahop Whitelist 105 | .DESCRIPTION 106 | This function allows you to remove a device from a whitelist. 107 | .EXAMPLE 108 | Remove-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 109 | .EXAMPLE 110 | Remove-ExtrahopWhitelistDevices -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 111 | #> 112 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 113 | Param( 114 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 115 | [String]$apiKey, 116 | 117 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 118 | [String]$appliance, 119 | 120 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 121 | [switch]$AllowSelfSignedCert, 122 | 123 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 124 | [int]$id 125 | ) 126 | 127 | #Set Protocol type to work with Self Signed SSL Cert 128 | If($AllowSelfSignedCert){ 129 | #region Cert 130 | add-type @" 131 | using System.Net; 132 | using System.Security.Cryptography.X509Certificates; 133 | public class TrustAllCertsPolicy : ICertificatePolicy { 134 | public bool CheckValidationResult( 135 | ServicePoint srvPoint, X509Certificate certificate, 136 | WebRequest request, int certificateProblem) { 137 | return true; 138 | } 139 | } 140 | "@ 141 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 142 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 143 | #endregion 144 | } 145 | $Endpoint = '/whitelist/devices' 146 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 147 | $Root = "https://" + $appliance + "/api/v1" 148 | $URI = $Root + $Endpoint + "/" + $id 149 | Invoke-RestMethod -Method 'Remove' -Uri $uri -Headers $headers -ErrorAction Stop 150 | } -------------------------------------------------------------------------------- /1.0.0/Public/vLans.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopVlans{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Vlans 5 | .DESCRIPTION 6 | This function allows you to retrieve all vlans or a specific vlan. 7 | .EXAMPLE 8 | Get-ExtrahopVlans -apiKey $apikey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -id 11 11 | .EXAMPLE 12 | Get-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 13 | #> 14 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 15 | Param( 16 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 17 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 18 | [String]$apiKey, 19 | 20 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 21 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 22 | [String]$appliance, 23 | 24 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 25 | [switch]$AllowSelfSignedCert, 26 | 27 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 28 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False, HelpMessage='Tag ID to return.')] 29 | [int]$id 30 | ) 31 | 32 | #Set Protocol type to work with Self Signed SSL Cert 33 | If($AllowSelfSignedCert){ 34 | #region Cert 35 | add-type @" 36 | using System.Net; 37 | using System.Security.Cryptography.X509Certificates; 38 | public class TrustAllCertsPolicy : ICertificatePolicy { 39 | public bool CheckValidationResult( 40 | ServicePoint srvPoint, X509Certificate certificate, 41 | WebRequest request, int certificateProblem) { 42 | return true; 43 | } 44 | } 45 | "@ 46 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 47 | #endregion 48 | } 49 | $Endpoint = '/vlans' 50 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 51 | $Root = "https://" + $appliance + "/api/v1" 52 | #region Build URI 53 | switch ($PsCmdlet.ParameterSetName) 54 | { 55 | 'All' { 56 | $message = "Retrieving all vLans from $appliance @ $Uri" 57 | $URI = $Root + $Endpoint 58 | } 59 | 60 | 'ByID' { 61 | $message = "Retrieving vLan {$id} from $appliance @ $Uri" 62 | $URI = $Root + $Endpoint + '/' + $ID 63 | } 64 | } 65 | 66 | #endregion 67 | Write-Host $message 68 | $vLans = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 69 | Return $vLans 70 | } 71 | 72 | Function Update-ExtrahopVlans{ 73 | <# 74 | .SYNOPSIS 75 | Function to update an Extrahop Vlan. 76 | .DESCRIPTION 77 | This function allows you to update the friendly name or description of 78 | a specific vlan. 79 | .EXAMPLE 80 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" 81 | .EXAMPLE 82 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -description "Vlan is used for voip devices." 83 | .EXAMPLE 84 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" -description "Vlan is used for voip devices." 85 | .EXAMPLE 86 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" -description "Vlan is used for voip devices." -AllowSelfSignedCert 87 | #> 88 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='Description')] 89 | Param( 90 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 91 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 92 | [String]$apiKey, 93 | 94 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 95 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 96 | [String]$appliance, 97 | 98 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 99 | [switch]$AllowSelfSignedCert, 100 | 101 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 102 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 103 | [string]$id, 104 | 105 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 106 | [Parameter(Mandatory=$false,ParameterSetName = 'FriendlyName')] 107 | [string]$description, 108 | 109 | [Parameter(Mandatory=$false,ParameterSetName = 'Description')] 110 | [Parameter(Mandatory=$true,ParameterSetName = 'FriendlyName')] 111 | [string]$name 112 | ) 113 | 114 | #Set Protocol type to work with Self Signed SSL Cert 115 | If($AllowSelfSignedCert){ 116 | #region Cert 117 | add-type @" 118 | using System.Net; 119 | using System.Security.Cryptography.X509Certificates; 120 | public class TrustAllCertsPolicy : ICertificatePolicy { 121 | public bool CheckValidationResult( 122 | ServicePoint srvPoint, X509Certificate certificate, 123 | WebRequest request, int certificateProblem) { 124 | return true; 125 | } 126 | } 127 | "@ 128 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 129 | #endregion 130 | } 131 | $Endpoint = '/vlans' 132 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 133 | $Root = "https://" + $appliance + "/api/v1" 134 | $URI = $Root + $Endpoint + "/" + $id 135 | switch ($PsCmdlet.ParameterSetName){ 136 | 'Description' { 137 | If($friendlyname){ 138 | #region Body 139 | $Body = @" 140 | { 141 | "description" : $description, 142 | "name" : $name 143 | } 144 | "@ 145 | #endregion 146 | } 147 | Else{ 148 | #region Body 149 | $Body = @" 150 | { 151 | "description" : $description 152 | } 153 | "@ 154 | #endregion 155 | } 156 | } 157 | 158 | 'FriendlyName' { 159 | If($description){ 160 | #region Body 161 | $Body = @" 162 | { 163 | "description" : $description, 164 | "name" : $name 165 | } 166 | "@ 167 | #endregion 168 | } 169 | Else{ 170 | #region Body 171 | $Body = @" 172 | { 173 | "name" : $name 174 | } 175 | "@ 176 | #endregion 177 | } 178 | } 179 | } 180 | Write-Host "Retrieving vLan {$id} from $appliance @ $Uri" 181 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 182 | } -------------------------------------------------------------------------------- /1.0.1/Public/vLans.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopVlans{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Vlans 5 | .DESCRIPTION 6 | This function allows you to retrieve all vlans or a specific vlan. 7 | .EXAMPLE 8 | Get-ExtrahopVlans -apiKey $apikey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -id 11 11 | .EXAMPLE 12 | Get-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -id 11 -AllowSelfSignedCert 13 | #> 14 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 15 | Param( 16 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 17 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 18 | [String]$apiKey, 19 | 20 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 21 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 22 | [String]$appliance, 23 | 24 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 25 | [switch]$AllowSelfSignedCert, 26 | 27 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 28 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False, HelpMessage='Tag ID to return.')] 29 | [int]$id 30 | ) 31 | 32 | #Set Protocol type to work with Self Signed SSL Cert 33 | If($AllowSelfSignedCert){ 34 | #region Cert 35 | add-type @" 36 | using System.Net; 37 | using System.Security.Cryptography.X509Certificates; 38 | public class TrustAllCertsPolicy : ICertificatePolicy { 39 | public bool CheckValidationResult( 40 | ServicePoint srvPoint, X509Certificate certificate, 41 | WebRequest request, int certificateProblem) { 42 | return true; 43 | } 44 | } 45 | "@ 46 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 47 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 48 | #endregion 49 | } 50 | $Endpoint = '/vlans' 51 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 52 | $Root = "https://" + $appliance + "/api/v1" 53 | #region Build URI 54 | switch ($PsCmdlet.ParameterSetName) 55 | { 56 | 'All' { 57 | $message = "Retrieving all vLans from $appliance @ $Uri" 58 | $URI = $Root + $Endpoint 59 | } 60 | 61 | 'ByID' { 62 | $message = "Retrieving vLan {$id} from $appliance @ $Uri" 63 | $URI = $Root + $Endpoint + '/' + $ID 64 | } 65 | } 66 | 67 | #endregion 68 | Write-Host $message 69 | $vLans = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 70 | Return $vLans 71 | } 72 | 73 | Function Update-ExtrahopVlans{ 74 | <# 75 | .SYNOPSIS 76 | Function to update an Extrahop Vlan. 77 | .DESCRIPTION 78 | This function allows you to update the friendly name or description of 79 | a specific vlan. 80 | .EXAMPLE 81 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" 82 | .EXAMPLE 83 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -description "Vlan is used for voip devices." 84 | .EXAMPLE 85 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" -description "Vlan is used for voip devices." 86 | .EXAMPLE 87 | Update-ExtrahopVlans -apiKey $apiKey -appliance 'Command Appliance' -friendlyname "vLan 35 (Voice)" -description "Vlan is used for voip devices." -AllowSelfSignedCert 88 | #> 89 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='Description')] 90 | Param( 91 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 92 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 93 | [String]$apiKey, 94 | 95 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 96 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 97 | [String]$appliance, 98 | 99 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 100 | [switch]$AllowSelfSignedCert, 101 | 102 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 103 | [Parameter(Mandatory=$True,ParameterSetName = 'FriendlyName')] 104 | [string]$id, 105 | 106 | [Parameter(Mandatory=$True,ParameterSetName = 'Description')] 107 | [Parameter(Mandatory=$false,ParameterSetName = 'FriendlyName')] 108 | [string]$description, 109 | 110 | [Parameter(Mandatory=$false,ParameterSetName = 'Description')] 111 | [Parameter(Mandatory=$true,ParameterSetName = 'FriendlyName')] 112 | [string]$name 113 | ) 114 | 115 | #Set Protocol type to work with Self Signed SSL Cert 116 | If($AllowSelfSignedCert){ 117 | #region Cert 118 | add-type @" 119 | using System.Net; 120 | using System.Security.Cryptography.X509Certificates; 121 | public class TrustAllCertsPolicy : ICertificatePolicy { 122 | public bool CheckValidationResult( 123 | ServicePoint srvPoint, X509Certificate certificate, 124 | WebRequest request, int certificateProblem) { 125 | return true; 126 | } 127 | } 128 | "@ 129 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 130 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 131 | #endregion 132 | } 133 | $Endpoint = '/vlans' 134 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 135 | $Root = "https://" + $appliance + "/api/v1" 136 | $URI = $Root + $Endpoint + "/" + $id 137 | switch ($PsCmdlet.ParameterSetName){ 138 | 'Description' { 139 | If($friendlyname){ 140 | #region Body 141 | $Body = @" 142 | { 143 | "description" : $description, 144 | "name" : $name 145 | } 146 | "@ 147 | #endregion 148 | } 149 | Else{ 150 | #region Body 151 | $Body = @" 152 | { 153 | "description" : $description 154 | } 155 | "@ 156 | #endregion 157 | } 158 | } 159 | 160 | 'FriendlyName' { 161 | If($description){ 162 | #region Body 163 | $Body = @" 164 | { 165 | "description" : $description, 166 | "name" : $name 167 | } 168 | "@ 169 | #endregion 170 | } 171 | Else{ 172 | #region Body 173 | $Body = @" 174 | { 175 | "name" : $name 176 | } 177 | "@ 178 | #endregion 179 | } 180 | } 181 | } 182 | Write-Host "Retrieving vLan {$id} from $appliance @ $Uri" 183 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 184 | } -------------------------------------------------------------------------------- /1.0.0/Public/Dashboards.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopDashboards{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop device groups. 5 | .DESCRIPTION 6 | This function allows you to retrieve device groups from extrahop. 7 | You can filter these groups using the regex enabled param 'name' and the 8 | bool param 'all' to decide if you want internal groups or not. You can also filter by ID 9 | and get certain properties of that devicegroup. 10 | .EXAMPLE 11 | $Splat = @{ 12 | apiKey = $apiKey 13 | appliance = $appliancename 14 | allowselfsignedcert = $True 15 | } 16 | Get-ExtrahopDashboards @Splat 17 | .EXAMPLE 18 | $Splat = @{ 19 | apiKey = $apikey 20 | appliance = $appliancename 21 | id = 15 22 | allowselfsignedcert = $True 23 | } 24 | Get-ExtrahopDashboards @Splat 25 | .EXAMPLE 26 | $Splat = @{ 27 | apiKey = $apikey 28 | appliance = $appliancename 29 | id = 15 30 | sharing = $true 31 | allowselfsignedcert = $True 32 | } 33 | Get-ExtrahopDashboards @Splat 34 | #> 35 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 36 | Param( 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$apiKey, 39 | 40 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [String]$appliance, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 44 | [string]$id, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 47 | [switch]$sharing, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [switch]$AllowSelfSignedCert 51 | ) 52 | 53 | #Set Protocol type to work with Self Signed SSL Cert 54 | If($AllowSelfSignedCert){ 55 | #region Cert 56 | add-type @" 57 | using System.Net; 58 | using System.Security.Cryptography.X509Certificates; 59 | public class TrustAllCertsPolicy : ICertificatePolicy { 60 | public bool CheckValidationResult( 61 | ServicePoint srvPoint, X509Certificate certificate, 62 | WebRequest request, int certificateProblem) { 63 | return true; 64 | } 65 | } 66 | "@ 67 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 68 | #endregion 69 | } 70 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 71 | $Root = "https://" + $appliance + "/api/v1" 72 | $Endpoint = '/dashboards' 73 | If($ID){ 74 | If($sharing){ 75 | $URI = $Root + $Endpoint + "/" + $id + "/" + "sharing" 76 | } 77 | Else{ 78 | $URI = $Root + $Endpoint + "/" + $id 79 | } 80 | } 81 | Else{ 82 | $URI = $Root + $Endpoint 83 | } 84 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 85 | } 86 | 87 | Function Update-ExtrahopDashboardOwner{ 88 | <# 89 | .SYNOPSIS 90 | Function to update the owner of a dashboard. 91 | .DESCRIPTION 92 | This function allows you to update the owner of a dashboard 93 | .EXAMPLE 94 | $Splat = @{ 95 | apiKey = $apiKey 96 | appliance = $appliancename 97 | id = 13 98 | owner = 'setup' 99 | AllowSelfSignedCert = $true 100 | } 101 | Update-ExtrahopDashboardOwner @Splat 102 | #> 103 | Param( 104 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 105 | [String]$apiKey, 106 | 107 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 108 | [String]$appliance, 109 | 110 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 111 | [string]$id, 112 | 113 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 114 | [string]$owner, 115 | 116 | [Parameter(Mandatory=$false)] 117 | [switch]$AllowSelfSignedCert 118 | ) 119 | 120 | #Set Protocol type to work with Self Signed SSL Cert 121 | If($AllowSelfSignedCert){ 122 | #region Cert 123 | add-type @" 124 | using System.Net; 125 | using System.Security.Cryptography.X509Certificates; 126 | public class TrustAllCertsPolicy : ICertificatePolicy { 127 | public bool CheckValidationResult( 128 | ServicePoint srvPoint, X509Certificate certificate, 129 | WebRequest request, int certificateProblem) { 130 | return true; 131 | } 132 | } 133 | "@ 134 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 135 | #endregion 136 | } 137 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 138 | $Root = "https://" + $appliance + "/api/v1" 139 | 140 | $Body = @{} 141 | $body.owner = $owner 142 | $jsonbody = ConvertTo-Json $Body 143 | $Endpoint = '/dashboards' 144 | $URI = $Root + $Endpoint + "/" + $id 145 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $jsonbody -ErrorAction Stop 146 | } 147 | 148 | Function Remove-ExtrahopDashboard{ 149 | <# 150 | .SYNOPSIS 151 | Function to remove Extrahop dashboards. 152 | .DESCRIPTION 153 | This function allows you to remove dashboards from extrahop. 154 | .EXAMPLE 155 | $Splat = @{ 156 | apiKey = $apiKey 157 | appliance = $appliancename 158 | id = '17' 159 | allowselfsignedcert = $True 160 | } 161 | Remove-ExtrahopDashboards @Splat 162 | #> 163 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 164 | Param( 165 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 166 | [String]$apiKey, 167 | 168 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [String]$appliance, 170 | 171 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 172 | [string]$id, 173 | 174 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 175 | [switch]$AllowSelfSignedCert 176 | ) 177 | 178 | #Set Protocol type to work with Self Signed SSL Cert 179 | If($AllowSelfSignedCert){ 180 | #region Cert 181 | add-type @" 182 | using System.Net; 183 | using System.Security.Cryptography.X509Certificates; 184 | public class TrustAllCertsPolicy : ICertificatePolicy { 185 | public bool CheckValidationResult( 186 | ServicePoint srvPoint, X509Certificate certificate, 187 | WebRequest request, int certificateProblem) { 188 | return true; 189 | } 190 | } 191 | "@ 192 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 193 | #endregion 194 | } 195 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 196 | $Root = "https://" + $appliance + "/api/v1" 197 | $Endpoint = '/dashboards' 198 | $URI = $Root + $Endpoint + "/" + $id 199 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 200 | } -------------------------------------------------------------------------------- /1.0.1/Public/Dashboards.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopDashboards{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop device groups. 5 | .DESCRIPTION 6 | This function allows you to retrieve device groups from extrahop. 7 | You can filter these groups using the regex enabled param 'name' and the 8 | bool param 'all' to decide if you want internal groups or not. You can also filter by ID 9 | and get certain properties of that devicegroup. 10 | .EXAMPLE 11 | $Splat = @{ 12 | apiKey = $apiKey 13 | appliance = $appliancename 14 | allowselfsignedcert = $True 15 | } 16 | Get-ExtrahopDashboards @Splat 17 | .EXAMPLE 18 | $Splat = @{ 19 | apiKey = $apikey 20 | appliance = $appliancename 21 | id = 15 22 | allowselfsignedcert = $True 23 | } 24 | Get-ExtrahopDashboards @Splat 25 | .EXAMPLE 26 | $Splat = @{ 27 | apiKey = $apikey 28 | appliance = $appliancename 29 | id = 15 30 | sharing = $true 31 | allowselfsignedcert = $True 32 | } 33 | Get-ExtrahopDashboards @Splat 34 | #> 35 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 36 | Param( 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$apiKey, 39 | 40 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [String]$appliance, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 44 | [string]$id, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 47 | [switch]$sharing, 48 | 49 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 50 | [switch]$AllowSelfSignedCert 51 | ) 52 | 53 | #Set Protocol type to work with Self Signed SSL Cert 54 | If($AllowSelfSignedCert){ 55 | #region Cert 56 | add-type @" 57 | using System.Net; 58 | using System.Security.Cryptography.X509Certificates; 59 | public class TrustAllCertsPolicy : ICertificatePolicy { 60 | public bool CheckValidationResult( 61 | ServicePoint srvPoint, X509Certificate certificate, 62 | WebRequest request, int certificateProblem) { 63 | return true; 64 | } 65 | } 66 | "@ 67 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 68 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 69 | #endregion 70 | } 71 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 72 | $Root = "https://" + $appliance + "/api/v1" 73 | $Endpoint = '/dashboards' 74 | If($ID){ 75 | If($sharing){ 76 | $URI = $Root + $Endpoint + "/" + $id + "/" + "sharing" 77 | } 78 | Else{ 79 | $URI = $Root + $Endpoint + "/" + $id 80 | } 81 | } 82 | Else{ 83 | $URI = $Root + $Endpoint 84 | } 85 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 86 | } 87 | 88 | Function Update-ExtrahopDashboardOwner{ 89 | <# 90 | .SYNOPSIS 91 | Function to update the owner of a dashboard. 92 | .DESCRIPTION 93 | This function allows you to update the owner of a dashboard 94 | .EXAMPLE 95 | $Splat = @{ 96 | apiKey = $apiKey 97 | appliance = $appliancename 98 | id = 13 99 | owner = 'setup' 100 | AllowSelfSignedCert = $true 101 | } 102 | Update-ExtrahopDashboardOwner @Splat 103 | #> 104 | Param( 105 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 106 | [String]$apiKey, 107 | 108 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 109 | [String]$appliance, 110 | 111 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 112 | [string]$id, 113 | 114 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 115 | [string]$owner, 116 | 117 | [Parameter(Mandatory=$false)] 118 | [switch]$AllowSelfSignedCert 119 | ) 120 | 121 | #Set Protocol type to work with Self Signed SSL Cert 122 | If($AllowSelfSignedCert){ 123 | #region Cert 124 | add-type @" 125 | using System.Net; 126 | using System.Security.Cryptography.X509Certificates; 127 | public class TrustAllCertsPolicy : ICertificatePolicy { 128 | public bool CheckValidationResult( 129 | ServicePoint srvPoint, X509Certificate certificate, 130 | WebRequest request, int certificateProblem) { 131 | return true; 132 | } 133 | } 134 | "@ 135 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 136 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 137 | #endregion 138 | } 139 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 140 | $Root = "https://" + $appliance + "/api/v1" 141 | 142 | $Body = @{} 143 | $body.owner = $owner 144 | $jsonbody = ConvertTo-Json $Body 145 | $Endpoint = '/dashboards' 146 | $URI = $Root + $Endpoint + "/" + $id 147 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $jsonbody -ErrorAction Stop 148 | } 149 | 150 | Function Remove-ExtrahopDashboard{ 151 | <# 152 | .SYNOPSIS 153 | Function to remove Extrahop dashboards. 154 | .DESCRIPTION 155 | This function allows you to remove dashboards from extrahop. 156 | .EXAMPLE 157 | $Splat = @{ 158 | apiKey = $apiKey 159 | appliance = $appliancename 160 | id = '17' 161 | allowselfsignedcert = $True 162 | } 163 | Remove-ExtrahopDashboards @Splat 164 | #> 165 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 166 | Param( 167 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 168 | [String]$apiKey, 169 | 170 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 171 | [String]$appliance, 172 | 173 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 174 | [string]$id, 175 | 176 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 177 | [switch]$AllowSelfSignedCert 178 | ) 179 | 180 | #Set Protocol type to work with Self Signed SSL Cert 181 | If($AllowSelfSignedCert){ 182 | #region Cert 183 | add-type @" 184 | using System.Net; 185 | using System.Security.Cryptography.X509Certificates; 186 | public class TrustAllCertsPolicy : ICertificatePolicy { 187 | public bool CheckValidationResult( 188 | ServicePoint srvPoint, X509Certificate certificate, 189 | WebRequest request, int certificateProblem) { 190 | return true; 191 | } 192 | } 193 | "@ 194 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 195 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 196 | #endregion 197 | } 198 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 199 | $Root = "https://" + $appliance + "/api/v1" 200 | $Endpoint = '/dashboards' 201 | $URI = $Root + $Endpoint + "/" + $id 202 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 203 | } -------------------------------------------------------------------------------- /1.0.0/Public/RunningConfig.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopRunningConfig{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop runningconfiguration. 5 | .DESCRIPTION 6 | This function allows you to retrieve the entire running configuration or one specific section. 7 | .EXAMPLE 8 | Get-ExtrahopRunningConfig -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopRunningConfig -apiKey $apiKey -appliance 'Command Appliance' -section 'dns' -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [switch]$AllowSelfSignedCert, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [string]$section 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 42 | #endregion 43 | } 44 | $Endpoint = '/runningconfig' 45 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 46 | $Root = "https://" + $appliance + "/api/v1" 47 | If($section){ 48 | $URI = $Root + $Endpoint + "?section" + "=" + $section.tolower() 49 | } 50 | Else{ 51 | $URI = $Root + $Endpoint 52 | } 53 | $vLans = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 54 | Return $vLans 55 | } 56 | 57 | Function Get-ExtrahopSavedConfig{ 58 | <# 59 | .SYNOPSIS 60 | Function to retrieve Extrahop SavedConfig 61 | .DESCRIPTION 62 | Function to retrieve Extrahop SavedConfig 63 | .EXAMPLE 64 | Get-ExtrahopSavedConfig -apiKey $APIKey -appliance "Command Appliance" -AllowSelfSignedCert 65 | .EXAMPLE 66 | Get-ExtrahopSavedConfig -apiKey $APIKey -appliance "Command Appliance" 67 | #> 68 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 69 | Param( 70 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 71 | [String]$apiKey, 72 | 73 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 74 | [String]$appliance, 75 | 76 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 77 | [switch]$AllowSelfSignedCert 78 | ) 79 | 80 | #Set Protocol type to work with Self Signed SSL Cert 81 | If($AllowSelfSignedCert){ 82 | #region Cert 83 | add-type @" 84 | using System.Net; 85 | using System.Security.Cryptography.X509Certificates; 86 | public class TrustAllCertsPolicy : ICertificatePolicy { 87 | public bool CheckValidationResult( 88 | ServicePoint srvPoint, X509Certificate certificate, 89 | WebRequest request, int certificateProblem) { 90 | return true; 91 | } 92 | } 93 | "@ 94 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 95 | #endregion 96 | } 97 | $Endpoint = '/runningconfig/saved' 98 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 99 | $Root = "https://" + $appliance + "/api/v1" 100 | $URI = $Root + $Endpoint 101 | $Config = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 102 | Return $Config 103 | } 104 | 105 | Function Save-ExtrahopRunningConfig{ 106 | <# 107 | .SYNOPSIS 108 | Function to save the Extrahop Runningconfig 109 | .DESCRIPTION 110 | Function to save the Extrahop Runningconfig 111 | .EXAMPLE 112 | Save-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -AllowSelfSignedCert 113 | .EXAMPLE 114 | Save-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" 115 | #> 116 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 117 | Param( 118 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 119 | [String]$apiKey, 120 | 121 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 122 | [String]$appliance, 123 | 124 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 125 | [switch]$AllowSelfSignedCert 126 | ) 127 | 128 | #Set Protocol type to work with Self Signed SSL Cert 129 | If($AllowSelfSignedCert){ 130 | #region Cert 131 | add-type @" 132 | using System.Net; 133 | using System.Security.Cryptography.X509Certificates; 134 | public class TrustAllCertsPolicy : ICertificatePolicy { 135 | public bool CheckValidationResult( 136 | ServicePoint srvPoint, X509Certificate certificate, 137 | WebRequest request, int certificateProblem) { 138 | return true; 139 | } 140 | } 141 | "@ 142 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 143 | #endregion 144 | } 145 | $Endpoint = '/runningconfig/save' 146 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 147 | $Root = "https://" + $appliance + "/api/v1" 148 | $URI = $Root + $Endpoint 149 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 150 | } 151 | 152 | Function Update-ExtrahopRunningConfig{ 153 | <# 154 | .SYNOPSIS 155 | Function to update the extrahop config 156 | .DESCRIPTION 157 | This function allows you to pass a json formatted string for the config. 158 | .EXAMPLE 159 | Update-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -config $config -AllowSelfSignedCert 160 | .EXAMPLE 161 | Update-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -config $config 162 | #> 163 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 164 | Param( 165 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 166 | [String]$apiKey, 167 | 168 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [String]$appliance, 170 | 171 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 172 | [string]$config, 173 | 174 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 175 | [switch]$AllowSelfSignedCert 176 | ) 177 | 178 | #Set Protocol type to work with Self Signed SSL Cert 179 | If($AllowSelfSignedCert){ 180 | #region Cert 181 | add-type @" 182 | using System.Net; 183 | using System.Security.Cryptography.X509Certificates; 184 | public class TrustAllCertsPolicy : ICertificatePolicy { 185 | public bool CheckValidationResult( 186 | ServicePoint srvPoint, X509Certificate certificate, 187 | WebRequest request, int certificateProblem) { 188 | return true; 189 | } 190 | } 191 | "@ 192 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 193 | #endregion 194 | } 195 | $Endpoint = '/runningconfig' 196 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 197 | $Root = "https://" + $appliance + "/api/v1" 198 | $URI = $Root + $Endpoint 199 | Invoke-RestMethod -Method Put -Uri $uri -Headers $headers -body $config -ErrorAction Stop 200 | } -------------------------------------------------------------------------------- /1.0.1/Public/RunningConfig.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopRunningConfig{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop runningconfiguration. 5 | .DESCRIPTION 6 | This function allows you to retrieve the entire running configuration or one specific section. 7 | .EXAMPLE 8 | Get-ExtrahopRunningConfig -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopRunningConfig -apiKey $apiKey -appliance 'Command Appliance' -section 'dns' -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [switch]$AllowSelfSignedCert, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [string]$section 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 42 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 43 | #endregion 44 | } 45 | $Endpoint = '/runningconfig' 46 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 47 | $Root = "https://" + $appliance + "/api/v1" 48 | If($section){ 49 | $URI = $Root + $Endpoint + "?section" + "=" + $section.tolower() 50 | } 51 | Else{ 52 | $URI = $Root + $Endpoint 53 | } 54 | $vLans = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 55 | Return $vLans 56 | } 57 | 58 | Function Get-ExtrahopSavedConfig{ 59 | <# 60 | .SYNOPSIS 61 | Function to retrieve Extrahop SavedConfig 62 | .DESCRIPTION 63 | Function to retrieve Extrahop SavedConfig 64 | .EXAMPLE 65 | Get-ExtrahopSavedConfig -apiKey $APIKey -appliance "Command Appliance" -AllowSelfSignedCert 66 | .EXAMPLE 67 | Get-ExtrahopSavedConfig -apiKey $APIKey -appliance "Command Appliance" 68 | #> 69 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 70 | Param( 71 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 72 | [String]$apiKey, 73 | 74 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 75 | [String]$appliance, 76 | 77 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 78 | [switch]$AllowSelfSignedCert 79 | ) 80 | 81 | #Set Protocol type to work with Self Signed SSL Cert 82 | If($AllowSelfSignedCert){ 83 | #region Cert 84 | add-type @" 85 | using System.Net; 86 | using System.Security.Cryptography.X509Certificates; 87 | public class TrustAllCertsPolicy : ICertificatePolicy { 88 | public bool CheckValidationResult( 89 | ServicePoint srvPoint, X509Certificate certificate, 90 | WebRequest request, int certificateProblem) { 91 | return true; 92 | } 93 | } 94 | "@ 95 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 96 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 97 | #endregion 98 | } 99 | $Endpoint = '/runningconfig/saved' 100 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 101 | $Root = "https://" + $appliance + "/api/v1" 102 | $URI = $Root + $Endpoint 103 | $Config = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 104 | Return $Config 105 | } 106 | 107 | Function Save-ExtrahopRunningConfig{ 108 | <# 109 | .SYNOPSIS 110 | Function to save the Extrahop Runningconfig 111 | .DESCRIPTION 112 | Function to save the Extrahop Runningconfig 113 | .EXAMPLE 114 | Save-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -AllowSelfSignedCert 115 | .EXAMPLE 116 | Save-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" 117 | #> 118 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 119 | Param( 120 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 121 | [String]$apiKey, 122 | 123 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 124 | [String]$appliance, 125 | 126 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 127 | [switch]$AllowSelfSignedCert 128 | ) 129 | 130 | #Set Protocol type to work with Self Signed SSL Cert 131 | If($AllowSelfSignedCert){ 132 | #region Cert 133 | add-type @" 134 | using System.Net; 135 | using System.Security.Cryptography.X509Certificates; 136 | public class TrustAllCertsPolicy : ICertificatePolicy { 137 | public bool CheckValidationResult( 138 | ServicePoint srvPoint, X509Certificate certificate, 139 | WebRequest request, int certificateProblem) { 140 | return true; 141 | } 142 | } 143 | "@ 144 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 145 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 146 | #endregion 147 | } 148 | $Endpoint = '/runningconfig/save' 149 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 150 | $Root = "https://" + $appliance + "/api/v1" 151 | $URI = $Root + $Endpoint 152 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 153 | } 154 | 155 | Function Update-ExtrahopRunningConfig{ 156 | <# 157 | .SYNOPSIS 158 | Function to update the extrahop config 159 | .DESCRIPTION 160 | This function allows you to pass a json formatted string for the config. 161 | .EXAMPLE 162 | Update-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -config $config -AllowSelfSignedCert 163 | .EXAMPLE 164 | Update-ExtrahopRunningConfig -apiKey $APIKey -appliance "Command Appliance" -config $config 165 | #> 166 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 167 | Param( 168 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [String]$apiKey, 170 | 171 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 172 | [String]$appliance, 173 | 174 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 175 | [string]$config, 176 | 177 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 178 | [switch]$AllowSelfSignedCert 179 | ) 180 | 181 | #Set Protocol type to work with Self Signed SSL Cert 182 | If($AllowSelfSignedCert){ 183 | #region Cert 184 | add-type @" 185 | using System.Net; 186 | using System.Security.Cryptography.X509Certificates; 187 | public class TrustAllCertsPolicy : ICertificatePolicy { 188 | public bool CheckValidationResult( 189 | ServicePoint srvPoint, X509Certificate certificate, 190 | WebRequest request, int certificateProblem) { 191 | return true; 192 | } 193 | } 194 | "@ 195 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 196 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 197 | #endregion 198 | } 199 | $Endpoint = '/runningconfig' 200 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 201 | $Root = "https://" + $appliance + "/api/v1" 202 | $URI = $Root + $Endpoint 203 | Invoke-RestMethod -Method Put -Uri $uri -Headers $headers -body $config -ErrorAction Stop 204 | } -------------------------------------------------------------------------------- /1.0.0/Public/Bundles.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopBundles{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop bundles. 5 | .DESCRIPTION 6 | This function allows you to retrieve Extrahop bundles. 7 | .EXAMPLE 8 | Get-ExtrahopBundles -apiKey $Apikey -appliance $appliancename 9 | .EXAMPLE 10 | Get-ExtrahopBundles -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [String]$id, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [switch]$AllowSelfSignedCert 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 42 | #endregion 43 | } 44 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 45 | $Root = "https://" + $appliance + "/api/v1" 46 | $endpoint = "/bundles" 47 | If($id){ 48 | $URI = $Root + $Endpoint + "/" + $id 49 | } 50 | Else{ 51 | $URI = $Root + $Endpoint 52 | } 53 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 54 | } 55 | 56 | Function Remove-ExtrahopBundles{ 57 | <# 58 | .SYNOPSIS 59 | Function to Remove Extrahop bundles. 60 | .DESCRIPTION 61 | This function allows you to Remove Extrahop bundles. 62 | .EXAMPLE 63 | Remove-ExtrahopBundles -apiKey $Apikey -appliance $appliancename 64 | .EXAMPLE 65 | Remove-ExtrahopBundles -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 66 | #> 67 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 68 | Param( 69 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 70 | [String]$apiKey, 71 | 72 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 73 | [String]$appliance, 74 | 75 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 76 | [String]$id, 77 | 78 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 79 | [switch]$AllowSelfSignedCert 80 | ) 81 | 82 | #Set Protocol type to work with Self Signed SSL Cert 83 | If($AllowSelfSignedCert){ 84 | #region Cert 85 | add-type @" 86 | using System.Net; 87 | using System.Security.Cryptography.X509Certificates; 88 | public class TrustAllCertsPolicy : ICertificatePolicy { 89 | public bool CheckValidationResult( 90 | ServicePoint srvPoint, X509Certificate certificate, 91 | WebRequest request, int certificateProblem) { 92 | return true; 93 | } 94 | } 95 | "@ 96 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 97 | #endregion 98 | } 99 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 100 | $Root = "https://" + $appliance + "/api/v1" 101 | $endpoint = "/bundles" 102 | $URI = $Root + $Endpoint + "/" + $id 103 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 104 | } 105 | 106 | Function Add-ExtrahopBundle{ 107 | <# 108 | .SYNOPSIS 109 | Function to upload an Extrahop bundles. 110 | .DESCRIPTION 111 | This function allows you to upload a JSON formatted Extrahop bundle. 112 | .EXAMPLE 113 | Add-ExtrahopBundle -apiKey $Apikey -appliance $appliancename -bundle $bundle 114 | #> 115 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 116 | Param( 117 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 118 | [String]$apiKey, 119 | 120 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 121 | [String]$appliance, 122 | 123 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 124 | [String]$bundle, 125 | 126 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 127 | [switch]$AllowSelfSignedCert 128 | ) 129 | 130 | #Set Protocol type to work with Self Signed SSL Cert 131 | If($AllowSelfSignedCert){ 132 | #region Cert 133 | add-type @" 134 | using System.Net; 135 | using System.Security.Cryptography.X509Certificates; 136 | public class TrustAllCertsPolicy : ICertificatePolicy { 137 | public bool CheckValidationResult( 138 | ServicePoint srvPoint, X509Certificate certificate, 139 | WebRequest request, int certificateProblem) { 140 | return true; 141 | } 142 | } 143 | "@ 144 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 145 | #endregion 146 | } 147 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 148 | $Root = "https://" + $appliance + "/api/v1" 149 | $endpoint = "/bundles" 150 | $URI = $Root + $Endpoint 151 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $bundle -ErrorAction Stop 152 | } 153 | 154 | Function Apply-ExtrahopBundle{ 155 | <# 156 | .SYNOPSIS 157 | Function to apply an Extrahop bundles. 158 | .DESCRIPTION 159 | This function allows you to apply an Extrahop bundle. 160 | .EXAMPLE 161 | Apply-ExtrahopBundle -apiKey $Apikey -appliance $appliancename 162 | #> 163 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 164 | Param( 165 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 166 | [String]$apiKey, 167 | 168 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [String]$appliance, 170 | 171 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 172 | [String]$id, 173 | 174 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 175 | [String]$include_assignments, 176 | 177 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 178 | [array]$node_ids, 179 | 180 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 181 | [string]$policy, 182 | 183 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 184 | [switch]$AllowSelfSignedCert 185 | ) 186 | 187 | #Set Protocol type to work with Self Signed SSL Cert 188 | If($AllowSelfSignedCert){ 189 | #region Cert 190 | add-type @" 191 | using System.Net; 192 | using System.Security.Cryptography.X509Certificates; 193 | public class TrustAllCertsPolicy : ICertificatePolicy { 194 | public bool CheckValidationResult( 195 | ServicePoint srvPoint, X509Certificate certificate, 196 | WebRequest request, int certificateProblem) { 197 | return true; 198 | } 199 | } 200 | "@ 201 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 202 | #endregion 203 | } 204 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 205 | $Root = "https://" + $appliance + "/api/v1" 206 | $endpoint = "/bundles" 207 | $URI = $Root + $Endpoint 208 | $array = $node_ids | convertto-json 209 | #region body 210 | $body = @" 211 | { 212 | "include_assignments": $include_assignments 213 | "node_ids": $array 214 | "policy": $policy 215 | } 216 | "@ 217 | #endregion 218 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 219 | } -------------------------------------------------------------------------------- /1.0.1/Public/Bundles.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopBundles{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop bundles. 5 | .DESCRIPTION 6 | This function allows you to retrieve Extrahop bundles. 7 | .EXAMPLE 8 | Get-ExtrahopBundles -apiKey $Apikey -appliance $appliancename 9 | .EXAMPLE 10 | Get-ExtrahopBundles -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 11 | #> 12 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 13 | Param( 14 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 15 | [String]$apiKey, 16 | 17 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 18 | [String]$appliance, 19 | 20 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 21 | [String]$id, 22 | 23 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 24 | [switch]$AllowSelfSignedCert 25 | ) 26 | 27 | #Set Protocol type to work with Self Signed SSL Cert 28 | If($AllowSelfSignedCert){ 29 | #region Cert 30 | add-type @" 31 | using System.Net; 32 | using System.Security.Cryptography.X509Certificates; 33 | public class TrustAllCertsPolicy : ICertificatePolicy { 34 | public bool CheckValidationResult( 35 | ServicePoint srvPoint, X509Certificate certificate, 36 | WebRequest request, int certificateProblem) { 37 | return true; 38 | } 39 | } 40 | "@ 41 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 42 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 43 | #endregion 44 | } 45 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 46 | $Root = "https://" + $appliance + "/api/v1" 47 | $endpoint = "/bundles" 48 | If($id){ 49 | $URI = $Root + $Endpoint + "/" + $id 50 | } 51 | Else{ 52 | $URI = $Root + $Endpoint 53 | } 54 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 55 | } 56 | 57 | Function Remove-ExtrahopBundles{ 58 | <# 59 | .SYNOPSIS 60 | Function to Remove Extrahop bundles. 61 | .DESCRIPTION 62 | This function allows you to Remove Extrahop bundles. 63 | .EXAMPLE 64 | Remove-ExtrahopBundles -apiKey $Apikey -appliance $appliancename 65 | .EXAMPLE 66 | Remove-ExtrahopBundles -apiKey $Apikey -appliance $appliancename -id 23 -AllowSelfSignedCert 67 | #> 68 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 69 | Param( 70 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 71 | [String]$apiKey, 72 | 73 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 74 | [String]$appliance, 75 | 76 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 77 | [String]$id, 78 | 79 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 80 | [switch]$AllowSelfSignedCert 81 | ) 82 | 83 | #Set Protocol type to work with Self Signed SSL Cert 84 | If($AllowSelfSignedCert){ 85 | #region Cert 86 | add-type @" 87 | using System.Net; 88 | using System.Security.Cryptography.X509Certificates; 89 | public class TrustAllCertsPolicy : ICertificatePolicy { 90 | public bool CheckValidationResult( 91 | ServicePoint srvPoint, X509Certificate certificate, 92 | WebRequest request, int certificateProblem) { 93 | return true; 94 | } 95 | } 96 | "@ 97 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 98 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 99 | #endregion 100 | } 101 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 102 | $Root = "https://" + $appliance + "/api/v1" 103 | $endpoint = "/bundles" 104 | $URI = $Root + $Endpoint + "/" + $id 105 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 106 | } 107 | 108 | Function Add-ExtrahopBundle{ 109 | <# 110 | .SYNOPSIS 111 | Function to upload an Extrahop bundles. 112 | .DESCRIPTION 113 | This function allows you to upload a JSON formatted Extrahop bundle. 114 | .EXAMPLE 115 | Add-ExtrahopBundle -apiKey $Apikey -appliance $appliancename -bundle $bundle 116 | #> 117 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 118 | Param( 119 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 120 | [String]$apiKey, 121 | 122 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 123 | [String]$appliance, 124 | 125 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 126 | [String]$bundle, 127 | 128 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 129 | [switch]$AllowSelfSignedCert 130 | ) 131 | 132 | #Set Protocol type to work with Self Signed SSL Cert 133 | If($AllowSelfSignedCert){ 134 | #region Cert 135 | add-type @" 136 | using System.Net; 137 | using System.Security.Cryptography.X509Certificates; 138 | public class TrustAllCertsPolicy : ICertificatePolicy { 139 | public bool CheckValidationResult( 140 | ServicePoint srvPoint, X509Certificate certificate, 141 | WebRequest request, int certificateProblem) { 142 | return true; 143 | } 144 | } 145 | "@ 146 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 147 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 148 | #endregion 149 | } 150 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 151 | $Root = "https://" + $appliance + "/api/v1" 152 | $endpoint = "/bundles" 153 | $URI = $Root + $Endpoint 154 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $bundle -ErrorAction Stop 155 | } 156 | 157 | Function Apply-ExtrahopBundle{ 158 | <# 159 | .SYNOPSIS 160 | Function to apply an Extrahop bundles. 161 | .DESCRIPTION 162 | This function allows you to apply an Extrahop bundle. 163 | .EXAMPLE 164 | Apply-ExtrahopBundle -apiKey $Apikey -appliance $appliancename 165 | #> 166 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 167 | Param( 168 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [String]$apiKey, 170 | 171 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 172 | [String]$appliance, 173 | 174 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 175 | [String]$id, 176 | 177 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 178 | [String]$include_assignments, 179 | 180 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 181 | [array]$node_ids, 182 | 183 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 184 | [string]$policy, 185 | 186 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 187 | [switch]$AllowSelfSignedCert 188 | ) 189 | 190 | #Set Protocol type to work with Self Signed SSL Cert 191 | If($AllowSelfSignedCert){ 192 | #region Cert 193 | add-type @" 194 | using System.Net; 195 | using System.Security.Cryptography.X509Certificates; 196 | public class TrustAllCertsPolicy : ICertificatePolicy { 197 | public bool CheckValidationResult( 198 | ServicePoint srvPoint, X509Certificate certificate, 199 | WebRequest request, int certificateProblem) { 200 | return true; 201 | } 202 | } 203 | "@ 204 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 205 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 206 | #endregion 207 | } 208 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 209 | $Root = "https://" + $appliance + "/api/v1" 210 | $endpoint = "/bundles" 211 | $URI = $Root + $Endpoint 212 | $array = $node_ids | convertto-json 213 | #region body 214 | $body = @" 215 | { 216 | "include_assignments": $include_assignments 217 | "node_ids": $array 218 | "policy": $policy 219 | } 220 | "@ 221 | #endregion 222 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $body -ErrorAction Stop 223 | } -------------------------------------------------------------------------------- /1.0.0/Public/Customizations.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopCustomizations{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop customizations. 5 | .DESCRIPTION 6 | This function allows you to retrieve customizations from extrahop. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopCustomizations @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 138 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopCustomizations @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | status = $true 27 | allowselfsignedcert = $True 28 | } 29 | Get-ExtrahopCustomizations @Splat 30 | #> 31 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 32 | Param( 33 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 34 | [String]$apiKey, 35 | 36 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 37 | [String]$appliance, 38 | 39 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'filter')] 40 | [switch]$status, 41 | 42 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 43 | [string]$id, 44 | 45 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 46 | [switch]$AllowSelfSignedCert 47 | ) 48 | 49 | #Set Protocol type to work with Self Signed SSL Cert 50 | If($AllowSelfSignedCert){ 51 | #region Cert 52 | add-type @" 53 | using System.Net; 54 | using System.Security.Cryptography.X509Certificates; 55 | public class TrustAllCertsPolicy : ICertificatePolicy { 56 | public bool CheckValidationResult( 57 | ServicePoint srvPoint, X509Certificate certificate, 58 | WebRequest request, int certificateProblem) { 59 | return true; 60 | } 61 | } 62 | "@ 63 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 64 | #endregion 65 | } 66 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 67 | $Root = "https://" + $appliance + "/api/v1" 68 | $Endpoint = '/customizations' 69 | If($ID){ 70 | $URI = $Root + $Endpoint + "/" + $id 71 | } 72 | Elseif($status){ 73 | $URI = $Root + $Endpoint + "/status" 74 | } 75 | Else{ 76 | $URI = $Root + $Endpoint 77 | } 78 | 79 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 80 | } 81 | 82 | Function New-ExtrahopCustomizationBackupFile{ 83 | <# 84 | .SYNOPSIS 85 | Function to create Extrahop backup 86 | .DESCRIPTION 87 | This function allows you to create a new backup file for extrahop. 88 | .EXAMPLE 89 | $Splat = @{ 90 | apiKey = $apiKey 91 | appliance = $appliancename 92 | backupName = 'Test Backup' 93 | allowselfsignedcert = $True 94 | } 95 | New-ExtrahopCustomizationBackupFile @Splat 96 | #> 97 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 98 | Param( 99 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 100 | [String]$apiKey, 101 | 102 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 103 | [String]$appliance, 104 | 105 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 106 | [string]$backupName, 107 | 108 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 109 | [switch]$AllowSelfSignedCert 110 | ) 111 | 112 | #Set Protocol type to work with Self Signed SSL Cert 113 | If($AllowSelfSignedCert){ 114 | #region Cert 115 | add-type @" 116 | using System.Net; 117 | using System.Security.Cryptography.X509Certificates; 118 | public class TrustAllCertsPolicy : ICertificatePolicy { 119 | public bool CheckValidationResult( 120 | ServicePoint srvPoint, X509Certificate certificate, 121 | WebRequest request, int certificateProblem) { 122 | return true; 123 | } 124 | } 125 | "@ 126 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 127 | #endregion 128 | } 129 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 130 | $Root = "https://" + $appliance + "/api/v1" 131 | $Endpoint = '/customizations' 132 | $Body = @{} 133 | $body.name = $backupName 134 | $body = $body | convertto-json 135 | $URI = $Root + $Endpoint 136 | 137 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 138 | } 139 | 140 | Function Restore-ExtrahopCustomizationFromBackup{ 141 | <# 142 | .SYNOPSIS 143 | Function to restore an extrahop backup from file. 144 | .DESCRIPTION 145 | This function allows you to restore an extrahop backup from file. 146 | .EXAMPLE 147 | $Splat = @{ 148 | apiKey = $apiKey 149 | appliance = $appliancename 150 | id = 3 151 | allowselfsignedcert = $True 152 | } 153 | Restore-ExtrahopCustomizationFromBackup @Splat 154 | #> 155 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 156 | Param( 157 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 158 | [String]$apiKey, 159 | 160 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 161 | [String]$appliance, 162 | 163 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 164 | [string]$id, 165 | 166 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 167 | [switch]$AllowSelfSignedCert 168 | ) 169 | 170 | #Set Protocol type to work with Self Signed SSL Cert 171 | If($AllowSelfSignedCert){ 172 | #region Cert 173 | add-type @" 174 | using System.Net; 175 | using System.Security.Cryptography.X509Certificates; 176 | public class TrustAllCertsPolicy : ICertificatePolicy { 177 | public bool CheckValidationResult( 178 | ServicePoint srvPoint, X509Certificate certificate, 179 | WebRequest request, int certificateProblem) { 180 | return true; 181 | } 182 | } 183 | "@ 184 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 185 | #endregion 186 | } 187 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 188 | $Root = "https://" + $appliance + "/api/v1" 189 | $Endpoint = '/customizations' 190 | $URI = $Root + $Endpoint + "/" + $id + "/" + "apply" 191 | 192 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 193 | } 194 | 195 | Function Remove-ExtrahopBackupFile{ 196 | <# 197 | .SYNOPSIS 198 | Function to delete an Extrahop backup file. 199 | .DESCRIPTION 200 | This function allows you to delete an Extrahop backup file. 201 | .EXAMPLE 202 | $Splat = @{ 203 | apiKey = $apiKey 204 | appliance = $appliancename 205 | id = 3 206 | allowselfsignedcert = $True 207 | } 208 | Remove-ExtrahopBackupFile @Splat 209 | #> 210 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 211 | Param( 212 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 213 | [String]$apiKey, 214 | 215 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 216 | [String]$appliance, 217 | 218 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 219 | [string]$id, 220 | 221 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 222 | [switch]$AllowSelfSignedCert 223 | ) 224 | 225 | #Set Protocol type to work with Self Signed SSL Cert 226 | If($AllowSelfSignedCert){ 227 | #region Cert 228 | add-type @" 229 | using System.Net; 230 | using System.Security.Cryptography.X509Certificates; 231 | public class TrustAllCertsPolicy : ICertificatePolicy { 232 | public bool CheckValidationResult( 233 | ServicePoint srvPoint, X509Certificate certificate, 234 | WebRequest request, int certificateProblem) { 235 | return true; 236 | } 237 | } 238 | "@ 239 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 240 | #endregion 241 | } 242 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 243 | $Root = "https://" + $appliance + "/api/v1" 244 | $Endpoint = '/customizations' 245 | $URI = $Root + $Endpoint + "/" + $id 246 | 247 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 248 | } 249 | -------------------------------------------------------------------------------- /1.0.1/Public/Customizations.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopCustomizations{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop customizations. 5 | .DESCRIPTION 6 | This function allows you to retrieve customizations from extrahop. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-ExtrahopCustomizations @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | id = 138 19 | allowselfsignedcert = $True 20 | } 21 | Get-ExtrahopCustomizations @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | status = $true 27 | allowselfsignedcert = $True 28 | } 29 | Get-ExtrahopCustomizations @Splat 30 | #> 31 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 32 | Param( 33 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 34 | [String]$apiKey, 35 | 36 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 37 | [String]$appliance, 38 | 39 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'filter')] 40 | [switch]$status, 41 | 42 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 43 | [string]$id, 44 | 45 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 46 | [switch]$AllowSelfSignedCert 47 | ) 48 | 49 | #Set Protocol type to work with Self Signed SSL Cert 50 | If($AllowSelfSignedCert){ 51 | #region Cert 52 | add-type @" 53 | using System.Net; 54 | using System.Security.Cryptography.X509Certificates; 55 | public class TrustAllCertsPolicy : ICertificatePolicy { 56 | public bool CheckValidationResult( 57 | ServicePoint srvPoint, X509Certificate certificate, 58 | WebRequest request, int certificateProblem) { 59 | return true; 60 | } 61 | } 62 | "@ 63 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 64 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 65 | #endregion 66 | } 67 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 68 | $Root = "https://" + $appliance + "/api/v1" 69 | $Endpoint = '/customizations' 70 | If($ID){ 71 | $URI = $Root + $Endpoint + "/" + $id 72 | } 73 | Elseif($status){ 74 | $URI = $Root + $Endpoint + "/status" 75 | } 76 | Else{ 77 | $URI = $Root + $Endpoint 78 | } 79 | 80 | Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 81 | } 82 | 83 | Function New-ExtrahopCustomizationBackupFile{ 84 | <# 85 | .SYNOPSIS 86 | Function to create Extrahop backup 87 | .DESCRIPTION 88 | This function allows you to create a new backup file for extrahop. 89 | .EXAMPLE 90 | $Splat = @{ 91 | apiKey = $apiKey 92 | appliance = $appliancename 93 | backupName = 'Test Backup' 94 | allowselfsignedcert = $True 95 | } 96 | New-ExtrahopCustomizationBackupFile @Splat 97 | #> 98 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 99 | Param( 100 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 101 | [String]$apiKey, 102 | 103 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 104 | [String]$appliance, 105 | 106 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 107 | [string]$backupName, 108 | 109 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 110 | [switch]$AllowSelfSignedCert 111 | ) 112 | 113 | #Set Protocol type to work with Self Signed SSL Cert 114 | If($AllowSelfSignedCert){ 115 | #region Cert 116 | add-type @" 117 | using System.Net; 118 | using System.Security.Cryptography.X509Certificates; 119 | public class TrustAllCertsPolicy : ICertificatePolicy { 120 | public bool CheckValidationResult( 121 | ServicePoint srvPoint, X509Certificate certificate, 122 | WebRequest request, int certificateProblem) { 123 | return true; 124 | } 125 | } 126 | "@ 127 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 128 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 129 | #endregion 130 | } 131 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 132 | $Root = "https://" + $appliance + "/api/v1" 133 | $Endpoint = '/customizations' 134 | $Body = @{} 135 | $body.name = $backupName 136 | $body = $body | convertto-json 137 | $URI = $Root + $Endpoint 138 | 139 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 140 | } 141 | 142 | Function Restore-ExtrahopCustomizationFromBackup{ 143 | <# 144 | .SYNOPSIS 145 | Function to restore an extrahop backup from file. 146 | .DESCRIPTION 147 | This function allows you to restore an extrahop backup from file. 148 | .EXAMPLE 149 | $Splat = @{ 150 | apiKey = $apiKey 151 | appliance = $appliancename 152 | id = 3 153 | allowselfsignedcert = $True 154 | } 155 | Restore-ExtrahopCustomizationFromBackup @Splat 156 | #> 157 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 158 | Param( 159 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 160 | [String]$apiKey, 161 | 162 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 163 | [String]$appliance, 164 | 165 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 166 | [string]$id, 167 | 168 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 169 | [switch]$AllowSelfSignedCert 170 | ) 171 | 172 | #Set Protocol type to work with Self Signed SSL Cert 173 | If($AllowSelfSignedCert){ 174 | #region Cert 175 | add-type @" 176 | using System.Net; 177 | using System.Security.Cryptography.X509Certificates; 178 | public class TrustAllCertsPolicy : ICertificatePolicy { 179 | public bool CheckValidationResult( 180 | ServicePoint srvPoint, X509Certificate certificate, 181 | WebRequest request, int certificateProblem) { 182 | return true; 183 | } 184 | } 185 | "@ 186 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 187 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 188 | #endregion 189 | } 190 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 191 | $Root = "https://" + $appliance + "/api/v1" 192 | $Endpoint = '/customizations' 193 | $URI = $Root + $Endpoint + "/" + $id + "/" + "apply" 194 | 195 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -ErrorAction Stop 196 | } 197 | 198 | Function Remove-ExtrahopBackupFile{ 199 | <# 200 | .SYNOPSIS 201 | Function to delete an Extrahop backup file. 202 | .DESCRIPTION 203 | This function allows you to delete an Extrahop backup file. 204 | .EXAMPLE 205 | $Splat = @{ 206 | apiKey = $apiKey 207 | appliance = $appliancename 208 | id = 3 209 | allowselfsignedcert = $True 210 | } 211 | Remove-ExtrahopBackupFile @Splat 212 | #> 213 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 214 | Param( 215 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 216 | [String]$apiKey, 217 | 218 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 219 | [String]$appliance, 220 | 221 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False,ParameterSetName = 'id')] 222 | [string]$id, 223 | 224 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 225 | [switch]$AllowSelfSignedCert 226 | ) 227 | 228 | #Set Protocol type to work with Self Signed SSL Cert 229 | If($AllowSelfSignedCert){ 230 | #region Cert 231 | add-type @" 232 | using System.Net; 233 | using System.Security.Cryptography.X509Certificates; 234 | public class TrustAllCertsPolicy : ICertificatePolicy { 235 | public bool CheckValidationResult( 236 | ServicePoint srvPoint, X509Certificate certificate, 237 | WebRequest request, int certificateProblem) { 238 | return true; 239 | } 240 | } 241 | "@ 242 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 243 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 244 | #endregion 245 | } 246 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 247 | $Root = "https://" + $appliance + "/api/v1" 248 | $Endpoint = '/customizations' 249 | $URI = $Root + $Endpoint + "/" + $id 250 | 251 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 252 | } 253 | -------------------------------------------------------------------------------- /1.0.0/Public/Users.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopUsers{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop users 5 | .DESCRIPTION 6 | This function allows you to retrieve users and their associated apiKeys. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-Extrahopusers @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | username = 'bobbydroptables;' 19 | allowselfsignedcert = $True 20 | } 21 | Get-Extrahopusers @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | username = 'bobbydroptables;' 27 | keys = $true 28 | allowselfsignedcert = $True 29 | } 30 | Get-Extrahopusers @Splat 31 | #> 32 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 33 | Param( 34 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 35 | [String]$apiKey, 36 | 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$appliance, 39 | 40 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [string]$username, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [switch]$keys, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [switch]$AllowSelfSignedCert 48 | ) 49 | 50 | #Set Protocol type to work with Self Signed SSL Cert 51 | If($AllowSelfSignedCert){ 52 | #region Cert 53 | add-type @" 54 | using System.Net; 55 | using System.Security.Cryptography.X509Certificates; 56 | public class TrustAllCertsPolicy : ICertificatePolicy { 57 | public bool CheckValidationResult( 58 | ServicePoint srvPoint, X509Certificate certificate, 59 | WebRequest request, int certificateProblem) { 60 | return true; 61 | } 62 | } 63 | "@ 64 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 65 | #endregion 66 | } 67 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 68 | $Root = "https://" + $appliance + "/api/v1" 69 | $Endpoint = '/users' 70 | If($username){ 71 | If($Keys){ 72 | $URI = $Root + $Endpoint + "/" + $username + "/" + "apikeys" 73 | } 74 | Else{ 75 | $URI = $Root + $Endpoint + "/" + $username 76 | } 77 | } 78 | Else{ 79 | $URI = $Root + $Endpoint 80 | } 81 | $users = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 82 | Return $users 83 | } 84 | 85 | Function New-ExtrahopUser{ 86 | <# 87 | .SYNOPSIS 88 | Function to create a new Extrahop user. 89 | .DESCRIPTION 90 | This function allows you to create a user in Extrahop and pass in various settings 91 | and properties. 92 | .EXAMPLE 93 | $Splat = @{ 94 | apiKey = $apiKey 95 | appliance = $appliancename 96 | name = 'Bobby dropTables;' 97 | password = 'dr0pDa-table$' 98 | username = 'bobdroptables;' 99 | allowselfsignedcert = $True 100 | } 101 | New-ExtrahopUser @Splat 102 | .EXAMPLE 103 | $Splat = @{ 104 | apiKey = $apiKey 105 | appliance = $appliancename 106 | name = 'Bobby dropTables;' 107 | password = 'dr0pDa-table$' 108 | username = 'bobdroptables;' 109 | create_apikey = $true 110 | enabled = $true 111 | granted_roles = $roles 112 | allowselfsignedcert = $True 113 | } 114 | New-ExtrahopUser @Splat 115 | #> 116 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 117 | Param( 118 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 119 | [String]$apiKey, 120 | 121 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 122 | [String]$appliance, 123 | 124 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 125 | [string]$username, 126 | 127 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 128 | [string]$name, 129 | 130 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 131 | [string]$password, 132 | 133 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 134 | [bool]$create_apikey, 135 | 136 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 137 | [bool]$enabled, 138 | 139 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 140 | [hashtable]$granted_roles, 141 | 142 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 143 | [switch]$AllowSelfSignedCert 144 | ) 145 | 146 | #Set Protocol type to work with Self Signed SSL Cert 147 | If($AllowSelfSignedCert){ 148 | #region Cert 149 | add-type @" 150 | using System.Net; 151 | using System.Security.Cryptography.X509Certificates; 152 | public class TrustAllCertsPolicy : ICertificatePolicy { 153 | public bool CheckValidationResult( 154 | ServicePoint srvPoint, X509Certificate certificate, 155 | WebRequest request, int certificateProblem) { 156 | return true; 157 | } 158 | } 159 | "@ 160 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 161 | #endregion 162 | } 163 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 164 | $Root = "https://" + $appliance + "/api/v1" 165 | $Endpoint = '/users' 166 | $URI = $Root + $Endpoint 167 | 168 | $Body = @{} 169 | If($create_apikey){ 170 | $body.create_apikey = $true 171 | } 172 | If($enabled){ 173 | $body.enabled = $true 174 | } 175 | If($granted_roles){ 176 | $body.granted_roles = $granted_roles 177 | } 178 | $body.name = $name 179 | $body.password = $password 180 | $body.username = $username 181 | $body = $body | convertto-json 182 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 183 | } 184 | 185 | Function Update-ExtrahopUser{ 186 | <# 187 | .SYNOPSIS 188 | Function to update an Extrahop user 189 | .DESCRIPTION 190 | This function allows you to update all of the user fields EXCEPT the username. 191 | .EXAMPLE 192 | $Splat = @{ 193 | apiKey = $apiKey 194 | appliance = $appliancename 195 | username = 'bobbydroptables;' 196 | name = 'newname' 197 | password = 'newpass' 198 | enabled = $True 199 | granted_roles = $Roles 200 | } 201 | Update-Extrahopuser @Splat 202 | #> 203 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 204 | Param( 205 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 206 | [String]$apiKey, 207 | 208 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 209 | [String]$appliance, 210 | 211 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 212 | [string]$username, 213 | 214 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 215 | [string]$name, 216 | 217 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 218 | [string]$password, 219 | 220 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 221 | [bool]$enabled, 222 | 223 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 224 | [hashtable]$granted_roles, 225 | 226 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 227 | [switch]$AllowSelfSignedCert 228 | ) 229 | 230 | #Set Protocol type to work with Self Signed SSL Cert 231 | If($AllowSelfSignedCert){ 232 | #region Cert 233 | add-type @" 234 | using System.Net; 235 | using System.Security.Cryptography.X509Certificates; 236 | public class TrustAllCertsPolicy : ICertificatePolicy { 237 | public bool CheckValidationResult( 238 | ServicePoint srvPoint, X509Certificate certificate, 239 | WebRequest request, int certificateProblem) { 240 | return true; 241 | } 242 | } 243 | "@ 244 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 245 | #endregion 246 | } 247 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 248 | $Root = "https://" + $appliance + "/api/v1" 249 | $Endpoint = '/users' 250 | $URI = $Root + $Endpoint + '/' + $username 251 | 252 | $Body = @{} 253 | If($enabled){ 254 | $body.enabled = $true 255 | } 256 | If($granted_roles){ 257 | $body.granted_roles = $granted_roles 258 | } 259 | If($name){ 260 | $body.name = $name 261 | } 262 | If($password){ 263 | $body.password = $password 264 | } 265 | $body = $body | convertto-json 266 | $body | out-file c:\temp\json.txt 267 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $body -ErrorAction Stop 268 | } 269 | 270 | Function Remove-ExtrahopUser{ 271 | <# 272 | .SYNOPSIS 273 | Function to remove an Extrahop user 274 | .DESCRIPTION 275 | This function allows you to remove a user completely. 276 | .EXAMPLE 277 | $Splat = @{ 278 | apiKey = $apiKey 279 | appliance = $appliancename 280 | username = 'bobbydroptables;' 281 | allowselfsignedcert = $True 282 | } 283 | Get-ExtrahopDevices @Splat 284 | #> 285 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 286 | Param( 287 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 288 | [String]$apiKey, 289 | 290 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 291 | [String]$appliance, 292 | 293 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 294 | [string]$username, 295 | 296 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 297 | [switch]$AllowSelfSignedCert 298 | ) 299 | 300 | #Set Protocol type to work with Self Signed SSL Cert 301 | If($AllowSelfSignedCert){ 302 | #region Cert 303 | add-type @" 304 | using System.Net; 305 | using System.Security.Cryptography.X509Certificates; 306 | public class TrustAllCertsPolicy : ICertificatePolicy { 307 | public bool CheckValidationResult( 308 | ServicePoint srvPoint, X509Certificate certificate, 309 | WebRequest request, int certificateProblem) { 310 | return true; 311 | } 312 | } 313 | "@ 314 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 315 | #endregion 316 | } 317 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 318 | $Root = "https://" + $appliance + "/api/v1" 319 | $Endpoint = '/users' 320 | $URI = $Root + $Endpoint + "/" + $username 321 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 322 | } -------------------------------------------------------------------------------- /1.0.1/Public/Users.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopUsers{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop users 5 | .DESCRIPTION 6 | This function allows you to retrieve users and their associated apiKeys. 7 | .EXAMPLE 8 | $Splat = @{ 9 | apiKey = $apiKey 10 | appliance = $appliancename 11 | allowselfsignedcert = $True 12 | } 13 | Get-Extrahopusers @Splat 14 | .EXAMPLE 15 | $Splat = @{ 16 | apiKey = $apiKey 17 | appliance = $appliancename 18 | username = 'bobbydroptables;' 19 | allowselfsignedcert = $True 20 | } 21 | Get-Extrahopusers @Splat 22 | .EXAMPLE 23 | $Splat = @{ 24 | apiKey = $apiKey 25 | appliance = $appliancename 26 | username = 'bobbydroptables;' 27 | keys = $true 28 | allowselfsignedcert = $True 29 | } 30 | Get-Extrahopusers @Splat 31 | #> 32 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 33 | Param( 34 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 35 | [String]$apiKey, 36 | 37 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [String]$appliance, 39 | 40 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 41 | [string]$username, 42 | 43 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 44 | [switch]$keys, 45 | 46 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 47 | [switch]$AllowSelfSignedCert 48 | ) 49 | 50 | #Set Protocol type to work with Self Signed SSL Cert 51 | If($AllowSelfSignedCert){ 52 | #region Cert 53 | add-type @" 54 | using System.Net; 55 | using System.Security.Cryptography.X509Certificates; 56 | public class TrustAllCertsPolicy : ICertificatePolicy { 57 | public bool CheckValidationResult( 58 | ServicePoint srvPoint, X509Certificate certificate, 59 | WebRequest request, int certificateProblem) { 60 | return true; 61 | } 62 | } 63 | "@ 64 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 65 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 66 | #endregion 67 | } 68 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 69 | $Root = "https://" + $appliance + "/api/v1" 70 | $Endpoint = '/users' 71 | If($username){ 72 | If($Keys){ 73 | $URI = $Root + $Endpoint + "/" + $username + "/" + "apikeys" 74 | } 75 | Else{ 76 | $URI = $Root + $Endpoint + "/" + $username 77 | } 78 | } 79 | Else{ 80 | $URI = $Root + $Endpoint 81 | } 82 | $users = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 83 | Return $users 84 | } 85 | 86 | Function New-ExtrahopUser{ 87 | <# 88 | .SYNOPSIS 89 | Function to create a new Extrahop user. 90 | .DESCRIPTION 91 | This function allows you to create a user in Extrahop and pass in various settings 92 | and properties. 93 | .EXAMPLE 94 | $Splat = @{ 95 | apiKey = $apiKey 96 | appliance = $appliancename 97 | name = 'Bobby dropTables;' 98 | password = 'dr0pDa-table$' 99 | username = 'bobdroptables;' 100 | allowselfsignedcert = $True 101 | } 102 | New-ExtrahopUser @Splat 103 | .EXAMPLE 104 | $Splat = @{ 105 | apiKey = $apiKey 106 | appliance = $appliancename 107 | name = 'Bobby dropTables;' 108 | password = 'dr0pDa-table$' 109 | username = 'bobdroptables;' 110 | create_apikey = $true 111 | enabled = $true 112 | granted_roles = $roles 113 | allowselfsignedcert = $True 114 | } 115 | New-ExtrahopUser @Splat 116 | #> 117 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 118 | Param( 119 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 120 | [String]$apiKey, 121 | 122 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 123 | [String]$appliance, 124 | 125 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 126 | [string]$username, 127 | 128 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 129 | [string]$name, 130 | 131 | [Parameter(Mandatory=$true,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 132 | [string]$password, 133 | 134 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 135 | [bool]$create_apikey, 136 | 137 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 138 | [bool]$enabled, 139 | 140 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 141 | [hashtable]$granted_roles, 142 | 143 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 144 | [switch]$AllowSelfSignedCert 145 | ) 146 | 147 | #Set Protocol type to work with Self Signed SSL Cert 148 | If($AllowSelfSignedCert){ 149 | #region Cert 150 | add-type @" 151 | using System.Net; 152 | using System.Security.Cryptography.X509Certificates; 153 | public class TrustAllCertsPolicy : ICertificatePolicy { 154 | public bool CheckValidationResult( 155 | ServicePoint srvPoint, X509Certificate certificate, 156 | WebRequest request, int certificateProblem) { 157 | return true; 158 | } 159 | } 160 | "@ 161 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 162 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 163 | #endregion 164 | } 165 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 166 | $Root = "https://" + $appliance + "/api/v1" 167 | $Endpoint = '/users' 168 | $URI = $Root + $Endpoint 169 | 170 | $Body = @{} 171 | If($create_apikey){ 172 | $body.create_apikey = $true 173 | } 174 | If($enabled){ 175 | $body.enabled = $true 176 | } 177 | If($granted_roles){ 178 | $body.granted_roles = $granted_roles 179 | } 180 | $body.name = $name 181 | $body.password = $password 182 | $body.username = $username 183 | $body = $body | convertto-json 184 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 185 | } 186 | 187 | Function Update-ExtrahopUser{ 188 | <# 189 | .SYNOPSIS 190 | Function to update an Extrahop user 191 | .DESCRIPTION 192 | This function allows you to update all of the user fields EXCEPT the username. 193 | .EXAMPLE 194 | $Splat = @{ 195 | apiKey = $apiKey 196 | appliance = $appliancename 197 | username = 'bobbydroptables;' 198 | name = 'newname' 199 | password = 'newpass' 200 | enabled = $True 201 | granted_roles = $Roles 202 | } 203 | Update-Extrahopuser @Splat 204 | #> 205 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 206 | Param( 207 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 208 | [String]$apiKey, 209 | 210 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 211 | [String]$appliance, 212 | 213 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 214 | [string]$username, 215 | 216 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 217 | [string]$name, 218 | 219 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 220 | [string]$password, 221 | 222 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 223 | [bool]$enabled, 224 | 225 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 226 | [hashtable]$granted_roles, 227 | 228 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 229 | [switch]$AllowSelfSignedCert 230 | ) 231 | 232 | #Set Protocol type to work with Self Signed SSL Cert 233 | If($AllowSelfSignedCert){ 234 | #region Cert 235 | add-type @" 236 | using System.Net; 237 | using System.Security.Cryptography.X509Certificates; 238 | public class TrustAllCertsPolicy : ICertificatePolicy { 239 | public bool CheckValidationResult( 240 | ServicePoint srvPoint, X509Certificate certificate, 241 | WebRequest request, int certificateProblem) { 242 | return true; 243 | } 244 | } 245 | "@ 246 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 247 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 248 | #endregion 249 | } 250 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 251 | $Root = "https://" + $appliance + "/api/v1" 252 | $Endpoint = '/users' 253 | $URI = $Root + $Endpoint + '/' + $username 254 | 255 | $Body = @{} 256 | If($enabled){ 257 | $body.enabled = $true 258 | } 259 | If($granted_roles){ 260 | $body.granted_roles = $granted_roles 261 | } 262 | If($name){ 263 | $body.name = $name 264 | } 265 | If($password){ 266 | $body.password = $password 267 | } 268 | $body = $body | convertto-json 269 | $body | out-file c:\temp\json.txt 270 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $body -ErrorAction Stop 271 | } 272 | 273 | Function Remove-ExtrahopUser{ 274 | <# 275 | .SYNOPSIS 276 | Function to remove an Extrahop user 277 | .DESCRIPTION 278 | This function allows you to remove a user completely. 279 | .EXAMPLE 280 | $Splat = @{ 281 | apiKey = $apiKey 282 | appliance = $appliancename 283 | username = 'bobbydroptables;' 284 | allowselfsignedcert = $True 285 | } 286 | Get-ExtrahopDevices @Splat 287 | #> 288 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 289 | Param( 290 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 291 | [String]$apiKey, 292 | 293 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 294 | [String]$appliance, 295 | 296 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 297 | [string]$username, 298 | 299 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 300 | [switch]$AllowSelfSignedCert 301 | ) 302 | 303 | #Set Protocol type to work with Self Signed SSL Cert 304 | If($AllowSelfSignedCert){ 305 | #region Cert 306 | add-type @" 307 | using System.Net; 308 | using System.Security.Cryptography.X509Certificates; 309 | public class TrustAllCertsPolicy : ICertificatePolicy { 310 | public bool CheckValidationResult( 311 | ServicePoint srvPoint, X509Certificate certificate, 312 | WebRequest request, int certificateProblem) { 313 | return true; 314 | } 315 | } 316 | "@ 317 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 318 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 319 | #endregion 320 | } 321 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 322 | $Root = "https://" + $appliance + "/api/v1" 323 | $Endpoint = '/users' 324 | $URI = $Root + $Endpoint + "/" + $username 325 | Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 326 | } -------------------------------------------------------------------------------- /1.0.0/Public/Tags.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopTags{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Tags 5 | .DESCRIPTION 6 | This function allows you to retrieve all tags, a specific tag, or all the devices for a tag. 7 | .EXAMPLE 8 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 11 | .EXAMPLE 12 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices 13 | .EXAMPLE 14 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices -AllowSelfSignedCert 15 | #> 16 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 17 | Param( 18 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 19 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 20 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 21 | [String]$apiKey, 22 | 23 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 24 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 25 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 26 | [String]$appliance, 27 | 28 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 29 | [switch]$AllowSelfSignedCert, 30 | 31 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 32 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 33 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 34 | [int]$id, 35 | 36 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 37 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [switch]$devices 39 | ) 40 | #Set Protocol type to work with Self Signed SSL Cert 41 | If($AllowSelfSignedCert){ 42 | #region Cert 43 | add-type @" 44 | using System.Net; 45 | using System.Security.Cryptography.X509Certificates; 46 | public class TrustAllCertsPolicy : ICertificatePolicy { 47 | public bool CheckValidationResult( 48 | ServicePoint srvPoint, X509Certificate certificate, 49 | WebRequest request, int certificateProblem) { 50 | return true; 51 | } 52 | } 53 | "@ 54 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 55 | #endregion 56 | } 57 | $Endpoint = '/tags' 58 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 59 | $Root = "https://" + $appliance + "/api/v1" 60 | #region Build URI 61 | switch ($PsCmdlet.ParameterSetName) 62 | { 63 | 'All' { 64 | $URI = $Root + $Endpoint 65 | } 66 | 67 | 'ByID' { 68 | $URI = $Root + $Endpoint + '/' + $ID 69 | } 70 | 71 | 'Devices' { 72 | $URI = $Root + $Endpoint + '/' + $ID + '/' + 'devices' 73 | } 74 | } 75 | 76 | #endregion 77 | Write-Host "Retrieving Tags from $appliance @ $Uri" 78 | $Tags = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 79 | Return $Tags 80 | } 81 | 82 | Function New-ExtrahopTag{ 83 | <# 84 | .SYNOPSIS 85 | Function to create a new Extrahop Tag 86 | .DESCRIPTION 87 | This function allows you to create a new tag on an appliance. 88 | .EXAMPLE 89 | New-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' 90 | .EXAMPLE 91 | New-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -AllowSelfSignedCert 92 | #> 93 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 94 | Param( 95 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 96 | [String]$apiKey, 97 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 98 | [String]$appliance, 99 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 100 | [string]$name, 101 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 102 | [switch]$AllowSelfSignedCert 103 | ) 104 | 105 | #Set Protocol type to work with Self Signed SSL Cert 106 | If($AllowSelfSignedCert){ 107 | #region Cert 108 | add-type @" 109 | using System.Net; 110 | using System.Security.Cryptography.X509Certificates; 111 | public class TrustAllCertsPolicy : ICertificatePolicy { 112 | public bool CheckValidationResult( 113 | ServicePoint srvPoint, X509Certificate certificate, 114 | WebRequest request, int certificateProblem) { 115 | return true; 116 | } 117 | } 118 | "@ 119 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 120 | #endregion 121 | } 122 | $Endpoint = '/tags' 123 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 124 | $Root = "https://" + $appliance + "/api/v1" 125 | $URI = $Root + $Endpoint 126 | $Body = @{ 127 | "name" = "$name" 128 | } | ConvertTo-JSON 129 | 130 | Write-Host "Creating Tag on $appliance" 131 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 132 | } 133 | 134 | Function Add-ExtrahopTagToDevices{ 135 | <# 136 | .SYNOPSIS 137 | Function to add an Existing Tag to a device(s) 138 | .DESCRIPTION 139 | This function allows you to create a new tag on an appliance. 140 | .EXAMPLE 141 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' 142 | .EXAMPLE 143 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -devices $Devices 144 | .EXAMPLE 145 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -devices $Devices -AllowSelfSignedcert 146 | #> 147 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 148 | Param( 149 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 150 | [String]$apiKey, 151 | 152 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 153 | [String]$appliance, 154 | 155 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 156 | [switch]$AllowSelfSignedCert, 157 | 158 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 159 | [string]$name, 160 | 161 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 162 | [array]$devices 163 | ) 164 | #Set Protocol type to work with Self Signed SSL Cert 165 | If($AllowSelfSignedCert){ 166 | #region Cert 167 | add-type @" 168 | using System.Net; 169 | using System.Security.Cryptography.X509Certificates; 170 | public class TrustAllCertsPolicy : ICertificatePolicy { 171 | public bool CheckValidationResult( 172 | ServicePoint srvPoint, X509Certificate certificate, 173 | WebRequest request, int certificateProblem) { 174 | return true; 175 | } 176 | } 177 | "@ 178 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 179 | #endregion 180 | } 181 | $Endpoint = '/tags' 182 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 183 | $Root = "https://" + $appliance + "/api/v1" 184 | $URI = $Root + $Endpoint 185 | $array = $devices | ConvertTo-JSON 186 | #region body 187 | $Body = @" 188 | { 189 | "assign" : $array 190 | } 191 | "@ 192 | #endregion 193 | Write-Host "Creating Tag on $appliance" 194 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 195 | } 196 | 197 | Function Remove-ExtrahopTag{ 198 | <# 199 | .SYNOPSIS 200 | Function to remove Extrahop Tags 201 | .DESCRIPTION 202 | This function allows you to remove a specific tag entirely or from one or more devices. 203 | .EXAMPLE 204 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 205 | .EXAMPLE 206 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices 207 | .EXAMPLE 208 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices -AllowSelfSignedCert 209 | #> 210 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 211 | Param( 212 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 213 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 214 | [String]$apiKey, 215 | 216 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 217 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 218 | [String]$appliance, 219 | 220 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 221 | [switch]$AllowSelfSignedCert, 222 | 223 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 224 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 225 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 226 | [int]$id, 227 | 228 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 229 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 230 | [switch]$devices 231 | ) 232 | #Set Protocol type to work with Self Signed SSL Cert 233 | If($AllowSelfSignedCert){ 234 | #region Cert 235 | add-type @" 236 | using System.Net; 237 | using System.Security.Cryptography.X509Certificates; 238 | public class TrustAllCertsPolicy : ICertificatePolicy { 239 | public bool CheckValidationResult( 240 | ServicePoint srvPoint, X509Certificate certificate, 241 | WebRequest request, int certificateProblem) { 242 | return true; 243 | } 244 | } 245 | "@ 246 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 247 | #endregion 248 | } 249 | $Endpoint = '/tags' 250 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 251 | $Root = "https://" + $appliance + "/api/v1" 252 | switch ($PsCmdlet.ParameterSetName){ 253 | 'ByID' { 254 | $URI = $Root + $Endpoint + '/' + $ID 255 | } 256 | 257 | 'Devices' { 258 | $URI = $Root + $Endpoint + '/' + $ID + '/' + 'devices' 259 | } 260 | } 261 | 262 | Write-Host "Retrieving Tags from $appliance @ $Uri" 263 | $Tags = Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 264 | Return $Tags 265 | } 266 | 267 | Function Edit-ExtrahopTag{ 268 | <# 269 | .SYNOPSIS 270 | Function to edit the name of an Existing Tag 271 | .DESCRIPTION 272 | This function allows you to change the name of a tag on an appliance. 273 | .EXAMPLE 274 | Edit-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -newTagName 'APITest' -id 11 275 | .EXAMPLE 276 | Edit-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -newTagName 'APITest' -id 11 -AllowSelfSignedCert 277 | #> 278 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 279 | Param( 280 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 281 | [String]$apiKey, 282 | 283 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 284 | [String]$appliance, 285 | 286 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 287 | [switch]$AllowSelfSignedCert, 288 | 289 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 290 | [string]$newTagName, 291 | 292 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 293 | [int]$id 294 | ) 295 | #Set Protocol type to work with Self Signed SSL Cert 296 | If($AllowSelfSignedCert){ 297 | #region Cert 298 | add-type @" 299 | using System.Net; 300 | using System.Security.Cryptography.X509Certificates; 301 | public class TrustAllCertsPolicy : ICertificatePolicy { 302 | public bool CheckValidationResult( 303 | ServicePoint srvPoint, X509Certificate certificate, 304 | WebRequest request, int certificateProblem) { 305 | return true; 306 | } 307 | } 308 | "@ 309 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 310 | #endregion 311 | } 312 | $Endpoint = '/tags' 313 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 314 | $Root = "https://" + $appliance + "/api/v1" 315 | $URI = $Root + $Endpoint + '/' + $id 316 | #region body 317 | $Body = @" 318 | { 319 | "name" : $name 320 | } 321 | "@ 322 | #endregion 323 | Write-Host "Renaming Tag {id:$id} to $name on $appliance" 324 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $body -ErrorAction Stop 325 | } -------------------------------------------------------------------------------- /1.0.1/Public/Tags.psm1: -------------------------------------------------------------------------------- 1 | Function Get-ExtrahopTags{ 2 | <# 3 | .SYNOPSIS 4 | Function to retrieve Extrahop Tags 5 | .DESCRIPTION 6 | This function allows you to retrieve all tags, a specific tag, or all the devices for a tag. 7 | .EXAMPLE 8 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' 9 | .EXAMPLE 10 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 11 | .EXAMPLE 12 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices 13 | .EXAMPLE 14 | Get-ExtrahopTags -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices -AllowSelfSignedCert 15 | #> 16 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 17 | Param( 18 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 19 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 20 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 21 | [String]$apiKey, 22 | 23 | [Parameter(Mandatory=$True,ParameterSetName = 'All')] 24 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 25 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 26 | [String]$appliance, 27 | 28 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 29 | [switch]$AllowSelfSignedCert, 30 | 31 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 32 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 33 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 34 | [int]$id, 35 | 36 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 37 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 38 | [switch]$devices 39 | ) 40 | #Set Protocol type to work with Self Signed SSL Cert 41 | If($AllowSelfSignedCert){ 42 | #region Cert 43 | add-type @" 44 | using System.Net; 45 | using System.Security.Cryptography.X509Certificates; 46 | public class TrustAllCertsPolicy : ICertificatePolicy { 47 | public bool CheckValidationResult( 48 | ServicePoint srvPoint, X509Certificate certificate, 49 | WebRequest request, int certificateProblem) { 50 | return true; 51 | } 52 | } 53 | "@ 54 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 55 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 56 | #endregion 57 | } 58 | $Endpoint = '/tags' 59 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 60 | $Root = "https://" + $appliance + "/api/v1" 61 | #region Build URI 62 | switch ($PsCmdlet.ParameterSetName) 63 | { 64 | 'All' { 65 | $URI = $Root + $Endpoint 66 | } 67 | 68 | 'ByID' { 69 | $URI = $Root + $Endpoint + '/' + $ID 70 | } 71 | 72 | 'Devices' { 73 | $URI = $Root + $Endpoint + '/' + $ID + '/' + 'devices' 74 | } 75 | } 76 | 77 | #endregion 78 | Write-Host "Retrieving Tags from $appliance @ $Uri" 79 | $Tags = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -ErrorAction Stop 80 | Return $Tags 81 | } 82 | 83 | Function New-ExtrahopTag{ 84 | <# 85 | .SYNOPSIS 86 | Function to create a new Extrahop Tag 87 | .DESCRIPTION 88 | This function allows you to create a new tag on an appliance. 89 | .EXAMPLE 90 | New-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' 91 | .EXAMPLE 92 | New-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -AllowSelfSignedCert 93 | #> 94 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 95 | Param( 96 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 97 | [String]$apiKey, 98 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 99 | [String]$appliance, 100 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 101 | [string]$name, 102 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 103 | [switch]$AllowSelfSignedCert 104 | ) 105 | 106 | #Set Protocol type to work with Self Signed SSL Cert 107 | If($AllowSelfSignedCert){ 108 | #region Cert 109 | add-type @" 110 | using System.Net; 111 | using System.Security.Cryptography.X509Certificates; 112 | public class TrustAllCertsPolicy : ICertificatePolicy { 113 | public bool CheckValidationResult( 114 | ServicePoint srvPoint, X509Certificate certificate, 115 | WebRequest request, int certificateProblem) { 116 | return true; 117 | } 118 | } 119 | "@ 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 122 | #endregion 123 | } 124 | $Endpoint = '/tags' 125 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 126 | $Root = "https://" + $appliance + "/api/v1" 127 | $URI = $Root + $Endpoint 128 | $Body = @{ 129 | "name" = "$name" 130 | } | ConvertTo-JSON 131 | 132 | Write-Host "Creating Tag on $appliance" 133 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 134 | } 135 | 136 | Function Add-ExtrahopTagToDevices{ 137 | <# 138 | .SYNOPSIS 139 | Function to add an Existing Tag to a device(s) 140 | .DESCRIPTION 141 | This function allows you to create a new tag on an appliance. 142 | .EXAMPLE 143 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' 144 | .EXAMPLE 145 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -devices $Devices 146 | .EXAMPLE 147 | Add-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -name 'APITest' -devices $Devices -AllowSelfSignedcert 148 | #> 149 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 150 | Param( 151 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 152 | [String]$apiKey, 153 | 154 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 155 | [String]$appliance, 156 | 157 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 158 | [switch]$AllowSelfSignedCert, 159 | 160 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 161 | [string]$name, 162 | 163 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 164 | [array]$devices 165 | ) 166 | #Set Protocol type to work with Self Signed SSL Cert 167 | If($AllowSelfSignedCert){ 168 | #region Cert 169 | add-type @" 170 | using System.Net; 171 | using System.Security.Cryptography.X509Certificates; 172 | public class TrustAllCertsPolicy : ICertificatePolicy { 173 | public bool CheckValidationResult( 174 | ServicePoint srvPoint, X509Certificate certificate, 175 | WebRequest request, int certificateProblem) { 176 | return true; 177 | } 178 | } 179 | "@ 180 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 181 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 182 | #endregion 183 | } 184 | $Endpoint = '/tags' 185 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 186 | $Root = "https://" + $appliance + "/api/v1" 187 | $URI = $Root + $Endpoint 188 | $array = $devices | ConvertTo-JSON 189 | #region body 190 | $Body = @" 191 | { 192 | "assign" : $array 193 | } 194 | "@ 195 | #endregion 196 | Write-Host "Creating Tag on $appliance" 197 | Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -body $body -ErrorAction Stop 198 | } 199 | 200 | Function Remove-ExtrahopTag{ 201 | <# 202 | .SYNOPSIS 203 | Function to remove Extrahop Tags 204 | .DESCRIPTION 205 | This function allows you to remove a specific tag entirely or from one or more devices. 206 | .EXAMPLE 207 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 208 | .EXAMPLE 209 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices 210 | .EXAMPLE 211 | Remove-ExtrahopTag -apiKey $apiKey -appliance 'Command Appliance' -id 11 -devices $devices -AllowSelfSignedCert 212 | #> 213 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low',DefaultParameterSetName='All')] 214 | Param( 215 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 216 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 217 | [String]$apiKey, 218 | 219 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 220 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 221 | [String]$appliance, 222 | 223 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 224 | [switch]$AllowSelfSignedCert, 225 | 226 | [Parameter(Mandatory=$True,ParameterSetName = 'ByID')] 227 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 228 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 229 | [int]$id, 230 | 231 | [Parameter(Mandatory=$True,ParameterSetName = 'Devices')] 232 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 233 | [switch]$devices 234 | ) 235 | #Set Protocol type to work with Self Signed SSL Cert 236 | If($AllowSelfSignedCert){ 237 | #region Cert 238 | add-type @" 239 | using System.Net; 240 | using System.Security.Cryptography.X509Certificates; 241 | public class TrustAllCertsPolicy : ICertificatePolicy { 242 | public bool CheckValidationResult( 243 | ServicePoint srvPoint, X509Certificate certificate, 244 | WebRequest request, int certificateProblem) { 245 | return true; 246 | } 247 | } 248 | "@ 249 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 250 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 251 | #endregion 252 | } 253 | $Endpoint = '/tags' 254 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 255 | $Root = "https://" + $appliance + "/api/v1" 256 | switch ($PsCmdlet.ParameterSetName){ 257 | 'ByID' { 258 | $URI = $Root + $Endpoint + '/' + $ID 259 | } 260 | 261 | 'Devices' { 262 | $URI = $Root + $Endpoint + '/' + $ID + '/' + 'devices' 263 | } 264 | } 265 | 266 | Write-Host "Retrieving Tags from $appliance @ $Uri" 267 | $Tags = Invoke-RestMethod -Method Delete -Uri $uri -Headers $headers -ErrorAction Stop 268 | Return $Tags 269 | } 270 | 271 | Function Edit-ExtrahopTag{ 272 | <# 273 | .SYNOPSIS 274 | Function to edit the name of an Existing Tag 275 | .DESCRIPTION 276 | This function allows you to change the name of a tag on an appliance. 277 | .EXAMPLE 278 | Edit-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -newTagName 'APITest' -id 11 279 | .EXAMPLE 280 | Edit-ExtrahopTag -apiKey $apiKey -appliance "Command Appliance" -newTagName 'APITest' -id 11 -AllowSelfSignedCert 281 | #> 282 | [CmdletBinding(SupportsShouldProcess=$False,ConfirmImpact='Low')] 283 | Param( 284 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 285 | [String]$apiKey, 286 | 287 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 288 | [String]$appliance, 289 | 290 | [Parameter(Mandatory=$false,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 291 | [switch]$AllowSelfSignedCert, 292 | 293 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 294 | [string]$newTagName, 295 | 296 | [Parameter(Mandatory=$True,ValueFromPipeline=$False,ValueFromPipelineByPropertyName = $False)] 297 | [int]$id 298 | ) 299 | #Set Protocol type to work with Self Signed SSL Cert 300 | If($AllowSelfSignedCert){ 301 | #region Cert 302 | add-type @" 303 | using System.Net; 304 | using System.Security.Cryptography.X509Certificates; 305 | public class TrustAllCertsPolicy : ICertificatePolicy { 306 | public bool CheckValidationResult( 307 | ServicePoint srvPoint, X509Certificate certificate, 308 | WebRequest request, int certificateProblem) { 309 | return true; 310 | } 311 | } 312 | "@ 313 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 314 | [System.Net.servicePointManager]::CertificatePolicy = New-Object TrustAllcertsPolicy 315 | #endregion 316 | } 317 | $Endpoint = '/tags' 318 | $headers = Get-ExtrahopHeaders -apiKey $apiKey 319 | $Root = "https://" + $appliance + "/api/v1" 320 | $URI = $Root + $Endpoint + '/' + $id 321 | #region body 322 | $Body = @" 323 | { 324 | "name" : $name 325 | } 326 | "@ 327 | #endregion 328 | Write-Host "Renaming Tag {id:$id} to $name on $appliance" 329 | Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -body $body -ErrorAction Stop 330 | } --------------------------------------------------------------------------------