Functions/FoldersFiles/Move-PVFile.ps1

Function Move-PVFile {

    <#
    .SYNOPSIS
    Moves a file or password to a different folder within the same Safe.

    .DESCRIPTION
    Exposes the PACLI Function: "MOVEFILE"

    .PARAMETER vault
    The defined Vault name

    .PARAMETER user
    The Username of the User carrying out the task.

    .PARAMETER safe
    The name of the Safe in which the file is stored.

    .PARAMETER folder
    The name of the folder in which the file is stored.

    .PARAMETER file
    The name of the file or password to move.

    .PARAMETER newFolder
    The name of the folder into which the file will be moved.

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

    .EXAMPLE
    Move-PVFile -vault lab -user administrator -safe AuditReports -folder root -file Report1 `
    -newFolder root\reports

    Move file Report1 to Reports folder within AuditReports safe.

    .NOTES
    AUTHOR: Pete Maan

    #>


    [CmdLetBinding()]
    param(

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

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

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

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

        [Parameter(
            Mandatory = $True,
            ValueFromPipelineByPropertyName = $True)]
        [Alias("Filename")]
        [string]$file,

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

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

    PROCESS {

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

        if($Return.ExitCode -eq 0) {

            Write-Verbose "File Moved"

            [PSCustomObject] @{

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

            } | Add-ObjectDetail -TypeName pacli.PoShPACLI

        }

    }

}