Copy-DscResource

Copies DSC resources.

Syntax

Copy-DscResource [-Path] <String> [-Destination] <String> [-Recurse] [-PassThru] [-Force] [<CommonParameters>]

Description

This function copies a DSC resource or a directory of DSC resources to a DSC pull server share/website. All files under $Path are copied.

DSC requires all files have a checksum file (e.g. localhost.mof.checksum), which this function generates for you (in a temporary location).

Only new files, or files whose checksums have changed, are copied. You can force all files to be copied with the Force switch.

Copy-DscResource is new in Carbon 2.0.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the DSC resource to copy. If a directory is given, all files in that directory are copied. Wildcards supported.

true false
Destination String

The directory where the resources should be copied.

true false
Recurse SwitchParameter

Recursively copy files from the source directory.

false false False
PassThru SwitchParameter

Returns IO.FileInfo objects for each item copied to Destination.

false false False
Force SwitchParameter

Copy resources, even if they are the same on the destination server.

false false False

Return Values

System.IO.FileInfo.

EXAMPLE 1

Copy-DscResource -Path 'localhost.mof' -Destination '\\dscserver\DscResources'

Demonstrates how to copy a single resource to a resources SMB share. localhost.mof will only be copied if its checksum is different than what is in \\dscserver\DscResources.

EXAMPLE 2

Copy-DscResource -Path 'C:\Projects\DscResources' -Destination '\\dscserver\DscResources'

Demonstrates how to copy a directory of resources. Only files in the directory are copied. Every file in the source must have a .checksum file. Only files whose checksums are different between source and destination will be copied.

EXAMPLE 3

Copy-DscResource -Path 'C:\Projects\DscResources' -Destination '\\dscserver\DscResources' -Recurse

Demonstrates how to recursively copy files.

EXAMPLE 4

Copy-DscResource -Path 'C:\Projects\DscResources' -Destination '\\dscserver\DscResources' -Force

Demonstrates how to copy all files, even if their .checksum files are the same.

EXAMPLE 5

Copy-DscResource -Path 'C:\Projects\DscResources' -Destination '\\dscserver\DscResources' -PassThru

Demonstrates how to get System.IO.FileInfo objects for all resources copied to the destination. If all files are up-to-date, nothing is copied, and no objects are returned.