Functions/Safes/Set-PVSafeFileCategory.ps1

Function Set-PVSafeFileCategory {

    <#
    .SYNOPSIS
    Update an existing File Category at Safe level

    .DESCRIPTION
    Exposes the PACLI Function: "UPDATESAFEFILECATEGORY"

    .PARAMETER vault
    The defined Vault name

    .PARAMETER user
    The Username of the authenticated User.

    .PARAMETER safe
    The Safe where the File Categories will be updated.

    .PARAMETER category
    The current name of the File Category.

    .PARAMETER categoryNewName
    The new name of the File Category.

    .PARAMETER validValues
    The valid values for the File Category.

    .PARAMETER defaultValue
    The default value for the File Category.

    .PARAMETER required
    Whether or not the File Category is a requirement when storing a file in
    the Safe.

    .PARAMETER sessionID
    The ID number of the session. Use this parameter when working
    with multiple scripts simultaneously. The default is ‘0’.

    .EXAMPLE
    Set-PVSafeFileCategory -vault lab -user administrator -safe SAFEName -category criticality `
    -categoryNewName sev -validValues "1,2,3,4"

    Changes Safe File Category name from "Criticality" to "sev"

    .NOTES
    AUTHOR: Pete Maan

    #>


    [CmdLetBinding(SupportsShouldProcess)]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "ShouldProcess handling is in Invoke-PACLICommand")]
    param(

        [Parameter(
            Mandatory = $True,
            ValueFromPipelineByPropertyName = $True)]
        [string]$vault,

        [Parameter(
            Mandatory = $True,
            ValueFromPipelineByPropertyName = $True)]
        [string]$user,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [Alias("Safename")]
        [String]$safe,

        [Parameter(
            Mandatory = $True,
            ValueFromPipelineByPropertyName = $True)]
        [string]$category,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [String]$categoryNewName,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [String]$validValues,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [String]$defaultValue,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [switch]$required,

        [Parameter(
            Mandatory = $False,
            ValueFromPipelineByPropertyName = $True)]
        [int]$sessionID
    )

    PROCESS {

        $Return = Invoke-PACLICommand $Script:PV.ClientPath UPDATESAFEFILECATEGORY $($PSBoundParameters.getEnumerator() |
                ConvertTo-ParameterString)

        if($Return.ExitCode -eq 0) {

            Write-Verbose "Safe File Category Updated"

            [PSCustomObject] @{

                "vault"     = $vault
                "user"      = $user
                "sessionID" = $sessionID

            } | Add-ObjectDetail -TypeName pacli.PoShPACLI

        }

    }

}