Public/Remove-LimeSession.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Function Remove-LimeSession {
    <#
    .SYNOPSIS
        Closes out LimeSurvey session and relases the session key
    .DESCRIPTION
        Closes out LimeSurvey session and relases the session key
    .PARAMETER Session
        LimeSurvey session to use (Created by New-LimeSession)
    .PARAMETER BaseUri
        Base URI for LimeSurvey
    .EXAMPLE
        Get-LimeParticipants -Session $Session -BaseUri https://limehost.com/index.php?r=admin/remotecontrol
    .FUNCTIONALITY
        LimeSurvey
    #>

    [CmdletBinding()]
    Param(
        [Parameter( Position = 1, ValueFromPipeLine = $true, ValueFromPipelineByPropertyName = $true )]
        [ValidateNotNull()]
        [string]$Session,

        [ValidateNotNull()]
        [string]$BaseUri
    )
    $RpcMethodBody = New-RpcMethod 'release_session_key' @($Session)
    $SessionKeyReleaseResult = Invoke-RpcMethod -RpcServerUri $BaseUri -RequestBody $RpcMethodBody

    if ($SessionKeyReleaseResult -ne 'OK') {
        Write-Error "Error releasing session key: $SessionKeyReleaseResult"
    }
    else {
        Write-Debug "Successfully released session key"
    }
}