Public/Set-ViewGroupXml.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
35
36
37
function Set-ViewGroupXml {
    [CmdletBinding()]
    param (
        # Specifies the View Group ID for which to retrieve the XML definition
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [guid]
        $Id,
        # Specifies the Xml data to update the specified View Group with
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]
        $Xml
    )

    begin {
        $svc = Get-IServerCommandService
    }

    process {
        $internalData = $svc.GetViewGroupData((Get-Token), $Id).ViewGroupData
        $internalData.ViewGroupDataXml = $Xml
        if ($internalData.DataVersion -eq [int]::MaxValue) {
            $internalData.DataVersion = 0
        }
        else {
            $internalData.DataVersion += 1
        }
        $result = $svc.SetViewGroupData((Get-Token), $Id, $internalData)
        if ($result -ne [VideoOS.Common.Proxy.Server.WCF.SetViewGroupDataResultType]::Success) {
            Write-Error $result.ToString()
        }
    }

    end {

    }
}