functions/set-d365azcopypath.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

<#
    .SYNOPSIS
        Set the path for AzCopy.exe
         
    .DESCRIPTION
        Update the path where the module will be looking for the AzCopy.exe executable
         
    .PARAMETER Path
        Path to the AzCopy.exe
         
    .EXAMPLE
        PS C:\> Invoke-D365InstallAzCopy -Path "C:\temp\d365fo.tools\AzCopy\AzCopy.exe"
         
        This will update the path for the AzCopy.exe in the modules configuration
         
    .NOTES
        Author: Mötz Jensen (@Splaxi)
#>

function Set-D365AzCopyPath {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
    [CmdletBinding()]
    [OutputType()]
    param (
        [Parameter(Mandatory = $true)]
        [string] $Path
    )

    if (-not (Test-PathExists -Path $Path -Type Leaf)) { return }

    if (Test-PSFFunctionInterrupt) { return }

    Set-PSFConfig -FullName "d365fo.tools.path.azcopy" -Value $Path
    
    Update-ModuleVariables
}