public/Remove-UnraidNotification.ps1
|
function Remove-UnraidNotification { <# .SYNOPSIS Deletes a notification. .PARAMETER InputObject Notification or ID to delete (accepts pipeline). .PARAMETER Session Unraid session (defaults to current session). .EXAMPLE Get-UnraidNotification -Type archive | Remove-UnraidNotification #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')] [OutputType('void')] param( [Parameter(Mandatory, ValueFromPipeline)] [object[]]$InputObject, [Parameter()] [UnraidSession]$Session = $script:DefaultUnraidSession ) process { foreach ($item in $InputObject) { if ($item -is [UnraidNotification]) { $id = $item.Id $desc = $item.Subject $type = if ($item.Type) { $item.Type } else { "ARCHIVE" } } else { $id = $item $desc = $id $type = "ARCHIVE" } if (! $id) { continue } if ($PSCmdlet.ShouldProcess("Notification: $desc", "Delete")) { $gqlQuery = "mutation { deleteNotification(id: `"$id`", type: $type) { unread { total } } }" Invoke-UnraidQuery -Query $gqlQuery -Session $Session | Out-Null } } } } |