PSSymantec.psm1

<#
.SYNOPSIS
Short description
 
.DESCRIPTION
Long description
 
.EXAMPLE
An example
 
.NOTES
General notes
#>

Function Get-RestErrorDetails{
    <#
    .SYNOPSIS
    Provides basic Rest Error Information from the API call in the event that the REST API call could not be performed successfully.
 
    .EXAMPLE
    try{
        Invoke-RestMethod -Method GET -URI $URI -headers $headers
    }catch{
        Get-RestErrorDetails
    }
    #>

        "An error was found with this command. Please review the resultant error for details."
        "Error Code:" + $_.Exception.Response.StatusCode.Value__ + " " +  $_.Exception.Response.ReasonPhrase
        "Error Message: " + $_
}
function Get-RestError($Error){
    #Allows backwards compatibility with older versions of Powershell
    if ($PSVersionTable.PSVersion.Major -lt 6) {
        if ($Error.Exception.Response) {  
            $Reader = New-Object System.IO.StreamReader($Error.Exception.Response.GetResponseStream())
            $Reader.BaseStream.Position = 0
            $Reader.DiscardBufferedData()
            $ResponseBody = $Reader.ReadToEnd()
            if ($ResponseBody.StartsWith('{')) {
                $ResponseBody = $ResponseBody | ConvertFrom-Json
            }
            return $ResponseBody
        }
        else {
            return $Error.ErrorDetails.Message
        }
    }
}
Function Get-SEPToken {
    <#
    .SYNOPSIS
    Generates a token that is used for the Symantec Console authentication process
    This requires the username, password (and domain if used).
     
    .DESCRIPTION
    Long description
     
    .EXAMPLE
    Get-SEPToken
    #>

    function Skip-Cert {
    <#
    .DESCRIPTION
    This function allows skipping the SSL/TLS Secure channel check in the event that there is not a valid certificate available
 
    .EXAMPLE
    Skip-Cert
    #>

    if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
        $certCallback = @"
        using System;
        using System.Net;
        using System.Net.Security;
        using System.Security.Cryptography.X509Certificates;
        public class ServerCertificateValidationCallback
        {
            public static void Ignore()
            {
                if(ServicePointManager.ServerCertificateValidationCallback ==null)
                {
                    ServicePointManager.ServerCertificateValidationCallback +=
                        delegate
                        (
                            Object obj,
                            X509Certificate certificate,
                            X509Chain chain,
                            SslPolicyErrors errors
                        )
                        {
                            return true;
                        };
                }
            }
        }
"@

    Add-Type $certCallback
 }
    [ServerCertificateValidationCallback]::Ignore()


    }

    if($null -eq $BaseURL){
        "Please enter your symantec server's name and port."
        "(e.g. <sepservername>:8446)"
        $ServerAddress = Read-Host -Prompt "Value"
        $Global:BaseURL = "https://" + $ServerAddress + '/sepm/api/v1'
    }
    $Creds = Get-Credential
    $body =@{
        "username" = $Creds.UserName
        "password" = ([System.Net.NetworkCredential]::new("", $Creds.Password).Password)
        "domain" = ""
    }

    if($null -ne $body){
        $URI = $BaseURL + '/identity/authenticate'
        try{
            Invoke-WebRequest $BaseURL
        }
        catch{
            'SSL Certificate test failed, skipping certificate validation. Please check your certificate settings and verify this is a legitimate source.'
            $Response = Read-Host -Prompt 'Please press enter to ignore this and continue without SSL/TLS secure channel'
            if($Response -eq ""){
                if($PSVersionTable.PSVersion.Major -lt 6){
                    Skip-Cert
                }
                if($PSVersionTable.PSVersion.Major -ge 6){
                    $Global:SkipCert = $true
                }
            }
        }
        try{
            if($PSVersionTable.PSVersion.Major -lt 6){
                $SEPToken = (Invoke-RestMethod -Method POST -Uri $URI -ContentType "application/json" -Body ($body | ConvertTo-Json)).token
            }
            if($PSVersionTable.PSVersion.Major -ge 6){
                if($Global:SkipCert -eq $true){
                    $SEPToken = (Invoke-RestMethod -Method POST -Uri $URI -ContentType "application/json" -Body ($body | ConvertTo-Json) -SkipCertificateCheck).token
                }else{
                    $SEPToken = (Invoke-RestMethod -Method POST -Uri $URI -ContentType "application/json" -Body ($body | ConvertTo-Json) -SkipCertificateCheck).token
                }
            }
        }
        catch{
            Get-RestErrorDetails
        }
    }
    $global:headers =@{
        "Authorization" = "Bearer $SEPToken"
        "Content" = 'application/json'
    }
}
Function Get-SEPComputers{
    <#
    .SYNOPSIS
    Displays a short or specific list of computers and their information from the Symantec Database
 
    .PARAMETER ComputerName
    Specifies the computer to return information on from the Symantec Database
 
    .EXAMPLE
    Get-SEPComputers -ComputerName TESTPC OR
    Get-SEPComputers
    #>

    [CmdletBinding()]
    Param (
    [Parameter()][ValidateNotNullOrEmpty()][String]$ComputerName
    )
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            if($null -ne $ComputerName){
                $URI = $BaseURL + "/computers?computerName=$ComputerName"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            } else{
                $URI = $BaseURL + '/computers'
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                if($null -ne $ComputerName){
                    $URI = $BaseURL + "/computers?computerName=$ComputerName"
                    try{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                    }catch{
                        "An error was found with this command. Please review the resultant error for details."
                        $RESTError = Get-RestError($_)
                        "Errors: $RESTError"
                    }
                } else{
                    $URI = $BaseURL + '/computers'
                    try{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                    }catch{
                        "An error was found with this command. Please review the resultant error for details."
                        $RESTError = Get-RestError($_)
                        "Errors: $RESTError"
                    }
                }
            }
        }
}
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            if($null -ne $ComputerName){
                $URI = $BaseURL + "/computers?computerName=$ComputerName"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                    }else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                    }
                }catch{
                    Get-RestErrorDetails
                }
            } else{
                $URI = $BaseURL + '/computers'
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                    }else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                    }
                }catch{
                   Get-RestErrorDetails
                }
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                if($null -ne $ComputerName){
                    $URI = $BaseURL + "/computers?computerName=$ComputerName"
                    try{
                        if($Global:SkipCert -eq $true){
                            (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                        }else{
                            (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                        }
                    }catch{
                        Get-RestErrorDetails
                    }
                } else{
                    $URI = $BaseURL + '/computers'
                    try{
                        if($Global:SkipCert -eq $true){
                            (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                        }else{
                            (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                        }
                    }catch{
                        Get-RestErrorDetails
                    }
                }
            }
        }
    }
}
function Start-SEPScan {
    [CmdletBinding()]
    Param (
    [Parameter(Mandatory)][ValidateNotNullOrEmpty()][String]$ComputerName,
    [Parameter(Mandatory)][ValidateSet('fullscan','activescan')][String[]]$ScanType
    )
    $ComputerID = (Get-SEPComputers -ComputerName $ComputerName).uniqueId
    $URI = $BaseURL + ("/command-queue/") + [string]$ScanType + "?computer_ids=" + $ComputerID
    if($PSVersionTable.PSVersion.Major -lt 6){
        try{
            $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
            if($null -ne $Result){
                "Scan Type: $ScanType, was successfully sent for: $ComputerName"
                $Result
            }
        }catch{
            "An error was found with this command. Please review the resultant error for details."
            $RESTError = Get-RestError($_)
            "Errors: $RESTError"
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        try{
            if($Global:SkipCert -eq $true){
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers -SkipCertificateCheck)
                if($null -ne $Result){
                    "Scan Type: $ScanType, was successfully sent for: $ComputerName"
                    $Result
                }
            }else{
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
                if($null -ne $Result){
                    "Scan Type: $ScanType, was successfully sent for: $ComputerName"
                    $Result
                }
            }
        }catch{
            Get-RestErrorDetails
        }
    }
}
function Set-SEPQuarantine {
    [CmdletBinding()]
    Param (
    [Parameter(Mandatory)][ValidateNotNullOrEmpty()][String]$ComputerName,
    [Parameter(Mandatory)][ValidateSet('true','false')][String[]]$Disabled
    )
    $ComputerID = (Get-SEPComputers -ComputerName $ComputerName).uniqueId
    $URI = $BaseURL + ("/command-queue/quarantine") + "?computer_ids=" + $ComputerID + "&undo=" + $Disabled
    if($PSVersionTable.PSVersion.Major -lt 6){
        try{
            $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
            if($null -ne $Result){
                "Quarantine Disabled: $Disabled, was successfully set for: $ComputerName"
                $Result
            }
        }catch{
            "An error was found with this command. Please review the resultant error for details."
            $RESTError = Get-RestError($_)
            "Errors: $RESTError"
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        try{
            if($Global:SkipCert -eq $true){
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers -SkipCertificateCheck)
                if($null -ne $Result){
                    "Quarantine Disabled: $Disabled, was successfully set for: $ComputerName"
                    $Result
                }
            } else{
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
                if($null -ne $Result){
                    "Quarantine Disabled: $Disabled, was successfully set for: $ComputerName"
                    $Result
                }
            }
        }catch{
            Get-RestErrorDetails
        }
    }
}
Function Get-SEPAdmins{
<#
.SYNOPSIS
Displays a list of admins in the Symantec Database
.EXAMPLE
Get-SEPAdmins
 
.PARAMETER AdminName
Displays only a specific user from the Admin List
Get-SEPAdmins -AdminName admin
 
.EXAMPLE
Get-SEPAdmins
 
.NOTES
General notes
#>

    [CmdletBinding()]
    Param (
    [Parameter()][String]$AdminName
    )
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/admin-users"
            try{
                $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                if($AdminName -eq ""){
                    $admins
                }
                if("" -ne $AdminName){
                    $admins  | Where-Object { $_.loginName -eq $AdminName }
                }
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/admin-users"
                try{
                    $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                    if($AdminName -eq ""){
                        $admins
                    }
                    if("" -ne $AdminName){
                        $admins  | Where-Object { $_.loginName -eq $AdminName }
                    }
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/admin-users"
            try{
                if($Global:SkipCert -eq $true){
                    $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck)
                    if($AdminName -eq ""){
                        $admins
                    }
                    if("" -ne $AdminName){
                        $admins  | Where-Object { $_.loginName -eq $AdminName }
                    }
                } else{
                    $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                    if($AdminName -eq ""){
                        $admins
                    }
                    if("" -ne $AdminName){
                        $admins  | Where-Object { $_.loginName -eq $AdminName }
                    } 
                }
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/admin-users"
                try{
                    if($Global:SkipCert -eq $true){
                        $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck)
                        if($AdminName -eq ""){
                            $admins
                        }
                        if("" -ne $AdminName){
                            $admins  | Where-Object { $_.loginName -eq $AdminName }
                        }
                    } else{
                        $admins = (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                        if($AdminName -eq ""){
                            $admins
                        }
                        if("" -ne $AdminName){
                            $admins  | Where-Object { $_.loginName -eq $AdminName }
                        } 
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Update-SEPClientInfo{
    [CmdletBinding()]
    Param (
    [Parameter(Mandatory)][ValidateNotNullOrEmpty()][String]$ComputerName
    )
    $ComputerID = (Get-SEPComputers -ComputerName $ComputerName).uniqueId
    $URI = $BaseURL + ("/command-queue/updatecontent?computer_ids=") + $ComputerID
    if($PSVersionTable.PSVersion.Major -lt 6){
        try{
            $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
            if($null -ne $Result){
                "Client information update request to: $ComputerName sent."
                $Result
            }
        }catch{
            "An error was found with this command. Please review the resultant error for details."
            $RESTError = Get-RestError($_)
            "Errors: $RESTError"
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        try{
            if($Global:SkipCert -eq $true){
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers -SkipCertificateCheck)
                if($null -ne $Result){
                    "Client information update request to: $ComputerName sent."
                    $Result
                }
            }else {
                $Result = (Invoke-RestMethod -Method POST -Uri $URI -Headers $headers)
                if($null -ne $Result){
                    "Client information update request to: $ComputerName sent."
                    $Result
                }
            }
        }catch{
            Get-RestErrorDetails
        }
    }
}
Function Get-SEPClientDefVersions{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/content"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientDefStatusList
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/content"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientDefStatusList
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/content"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientDefStatusList
                } else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientDefStatusList
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/content"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientDefStatusList
                    } else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientDefStatusList
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Get-SEPClientStatus{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/onlinestatus"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientCountStatsList
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/onlinestatus"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientCountStatsList
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/onlinestatus"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientCountStatsList
                } else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientCountStatsList
                }
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/onlinestatus"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientCountStatsList
                    } else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientCountStatsList
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }  
    }
}
Function Get-SEPClientVersions{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/version"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientVersionList
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/version"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientVersionList
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/client/version"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientVersionList
                } else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientVersionList
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/client/version"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).clientVersionList
                    } else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).clientVersionList
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Get-SEPClientThreatStats{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/threat"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).Stats
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/threat"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).Stats
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/stats/threat"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).Stats
                }else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).Stats
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/stats/threat"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).Stats
                    }else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).Stats
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Get-SEPMVersion{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/version"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/version"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/version"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck)
                }else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/version"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck)
                    }else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers)
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Get-SEPMFirewallPolicies{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/policies/summary/fw"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/policies/summary/fw"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/policies/summary/fw"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                } else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/policies/summary/fw"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).content
                    } else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).content
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}
Function Get-SEPMEventInfo{
    if($PSVersionTable.PSVersion.Major -lt 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/events/critical"
            try{
                (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).criticalEventsInfoList
            }catch{
                "An error was found with this command. Please review the resultant error for details."
                $RESTError = Get-RestError($_)
                "Errors: $RESTError"
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/events/critical"
                try{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).criticalEventsInfoList
                }catch{
                    "An error was found with this command. Please review the resultant error for details."
                    $RESTError = Get-RestError($_)
                    "Errors: $RESTError"
                }
            }
        }
    }
    if($PSVersionTable.PSVersion.Major -ge 6){
        if($null -ne $headers){
            $URI = $BaseURL + "/events/critical"
            try{
                if($Global:SkipCert -eq $true){
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).criticalEventsInfoList
                } else{
                    (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).criticalEventsInfoList
                }
            }catch{
                Get-RestErrorDetails
            }
        }
        if($null -eq $headers){
            Get-SEPToken
            if($null -ne $headers){
                $URI = $BaseURL + "/events/critical"
                try{
                    if($Global:SkipCert -eq $true){
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers -SkipCertificateCheck).criticalEventsInfoList
                    } else{
                        (Invoke-RestMethod -Method GET -Uri $URI -Headers $headers).criticalEventsInfoList
                    }
                }catch{
                    Get-RestErrorDetails
                }
            }
        }
    }
}