functions/Remove-Note.ps1
<#
.SYNOPSIS Removes a Note for a sensor ot sensorhub. .DESCRIPTION This will remove notes for a sensor/Sensorhub. .PARAMETER SensorId The id of the sensor for which the notifications should be removed. .PARAMETER SensorHubId The id of the SensorHub for which the notifications should be removed. .PARAMETER NoteID The id of the Note that should be removed. .PARAMETER AuthToken Either a session or an API key. If no AuthToken is provided the global Server-Eye session will be used if available. #> function Remove-Note { Param( [parameter(ValueFromPipelineByPropertyName,Mandatory=$false,ParameterSetName='ofSensor')] $SensorID, [parameter(ValueFromPipelineByPropertyName,Mandatory=$false,ParameterSetName='ofSensorHub')] $SensorhubId, [Parameter(ValueFromPipelineByPropertyName,Mandatory=$false,ParameterSetName='ofSensorHub')] [Parameter(ValueFromPipelineByPropertyName,Mandatory=$false,ParameterSetName='ofSensor')] $NoteID, [Parameter(Mandatory=$false,ParameterSetName='ofSensorHub')] [Parameter(Mandatory=$false,ParameterSetName='ofSensor')] $AuthToken ) Begin{ $AuthToken = Test-SEAuth -AuthToken $AuthToken } Process { if ($SensorID) { removeNotefromSensor -sensorId $SensorId -Noteid $noteid -auth $AuthToken }elseif ($SensorhubId) { removeNotefromSensorhub -SensorhubId $SensorhubId -noteid $noteid -auth $AuthToken } else { Write-Error "Unsupported input" } } End{ } } function removeNotefromSensorhub ($SensorhubId, $NoteID, $auth) { $Sensorhub = Get-SESensorhub -Sensorhubid $SensorhubId $note = Get-SENote -SensorhubId $SensorhubId | Where-Object {$_.NoteId -eq $noteID} Remove-SeApiContainerNote -AuthToken $auth -nid $NoteID -cid $SensorhubId [PSCustomObject]@{ NoteID = $NoteID Message = $note.Message PostedFrom = $note.PostedFrom Email = $note.Email Sensorhub = $Sensorhub.Name 'OCC-Connector' = $Sensorhub."OCC-Connector" Customer = $Sensorhub.Customer Removed = "Yes" } } function removeNotefromSensor ($SensorID, $NoteID, $auth) { $Sensor = Get-SESensor -SensorId $SensorID $note = Get-SENote -SensorId $SensorID | Where-Object {$_.NoteId -eq $noteID} Remove-SeApiAgentNote -AuthToken $auth -nid $noteID -aid $SensorID [PSCustomObject]@{ NoteID = $NoteID Message = $note.Message PostedFrom = $note.PostedFrom Email = $note.Email Sensor = $Sensor.Name Sensorhub = $Sensor.Sensorhub 'OCC-Connector' = $Sensor."OCC-Connector" Customer = $Sensor.Customer Removed = "Yes" } } # SIG # Begin signature block # MIIa0AYJKoZIhvcNAQcCoIIawTCCGr0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUlNfh5Z8dOHWcMLfs5flQnyIW # aiugghW/MIIEmTCCA4GgAwIBAgIPFojwOSVeY45pFDkH5jMLMA0GCSqGSIb3DQEB # BQUAMIGVMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQg # TGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNV # BAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTEdMBsGA1UEAxMUVVROLVVTRVJG # aXJzdC1PYmplY3QwHhcNMTUxMjMxMDAwMDAwWhcNMTkwNzA5MTg0MDM2WjCBhDEL # MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE # BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKjAoBgNVBAMT # IUNPTU9ETyBTSEEtMSBUaW1lIFN0YW1waW5nIFNpZ25lcjCCASIwDQYJKoZIhvcN # AQEBBQADggEPADCCAQoCggEBAOnpPd/XNwjJHjiyUlNCbSLxscQGBGue/YJ0UEN9 # xqC7H075AnEmse9D2IOMSPznD5d6muuc3qajDjscRBh1jnilF2n+SRik4rtcTv6O # KlR6UPDV9syR55l51955lNeWM/4Og74iv2MWLKPdKB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