Public/Get-DokuServerVersion.ps1

function Get-DokuServerVersion {
<#
    .SYNOPSIS
        Returns the DokuWiki version of the remote Wiki server
 
    .DESCRIPTION
        Returns the DokuWiki version of the remote Wiki server
 
    .PARAMETER DokuSession
        The DokuSession (generated by New-DokuSession) from which to get the page list.
 
    .EXAMPLE
        PS C:\> $Version = Get-DokuServerVersion -DokuSession $DokuSession
 
    .EXAMPLE
        PS C:\> $version = Get-DokuServerVersion -DokuSession $DokuSession
 
    .OUTPUTS
        System.Management.Automation.PSObject
 
    .NOTES
        AndyDLP - 2018-05-28
#>


    [CmdletBinding()]
    [OutputType([psobject])]
    param
    (
        [Parameter(Mandatory = $true,
                   Position = 1,
                   ValueFromPipeline = $true,
                   HelpMessage = 'The DokuSession from which to get the page list.')]
        [ValidateScript({ ($null -ne $_.WebSession ) -or ($_.Headers.Keys -contains "Authorization") })]
        [psobject]$DokuSession
    )

    begin {

    } # begin

    process {
        $APIResponse = Invoke-DokuApiCall -DokuSession $DokuSession -MethodName 'dokuwiki.getVersion' -MethodParameters @()
        if ($APIResponse.CompletedSuccessfully -eq $true) {
            $RawDokuVersion = [string]($APIResponse.XMLPayloadResponse | Select-Xml -XPath "//value/string").node.InnerText
            $CodeName = $RawDokuVersion | ForEach-Object -Process { [regex]::match($_, '(?<=")(.+)(?=")') } | Select-Object -ExpandProperty value
            $SplitVersion = $RawDokuVersion -split " "
            $VersionObject = New-Object PSObject -Property @{
                Server = $DokuSession.Server
                Type = $SplitVersion[0] # Does this ever change?
                ReleaseDate = $SplitVersion[1] # TODO: Convert to date time - replace letter(s)?
                ReleaseName = $CodeName
            }
            $VersionObject
        } elseif ($null -eq $APIResponse.ExceptionMessage) {
            Write-Error "Fault code: $($APIResponse.FaultCode) - Fault string: $($APIResponse.FaultString)"
        } else {
            Write-Error "Exception: $($APIResponse.ExceptionMessage)"
        }
    } # process

    end {

    } # end
}