functions/Copy-DSCResource.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Copy-DSCResource {
    [cmdletBinding()]
    Param($PSSession,$ModulestoCopy)
    
    foreach ($Module in $ModulestoCopy)
    {
        $Source = 'C:\Program Files\WindowsPowerShell\Modules\'+$Module.ModuleName
        Write-Verbose "Module location: $Source"
        $Destination = 'C:\Program Files\WindowsPowerShell\Modules\'
        try
        {
            Write-Verbose "Copying"
            Copy-Item -ToSession $PSSession -Path $Source -Destination $Destination -Recurse -Force -ErrorAction STOP -Verbose
            Write-Verbose "Copied"
        }
        catch
        {
            Write-Output $Error[0].Exception
            break
        }
    }

}