< Back

Copy-RemoteItemLocally

Sun Jan 12, 2020 5:58 pm

NAME Copy-RemoteItemLocally



SYNOPSIS

Copies a remote file/folder to a local destination





SYNTAX

Copy-RemoteItemLocally [-Source] <String> [[-Destination] <String>] [[-SourceCredential] <PSCredential>]

[-Directory] [<CommonParameters>]





DESCRIPTION

Utility function for copying remote files locally. It leverages windows net use to map a share folder and

supports network credentials for mounting the share.





PARAMETERS

-Source <String>

The path to the file/folder to copy. It could be a network share or a local file path.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Destination <String>

The path to the destination folder. This path should be local to the machine executing the script. If not

specified the item(s) will be copy to the temp folder



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SourceCredential <PSCredential>

Used if the source is a network share for authentication.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Directory [<SwitchParameter>]

Specifies if the source is a directory or a file



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\># Copy a remote file



Copy-RemoteItemLocally "\\\\otherpc\\sharedfolder\\myfile.doc" "C:\\Mydocs\\" (Get-Credential)



# Copy a remote directory

Copy-RemoteItemLocally "\\\\otherpc\\sharedfolder\\subfolder" "C:\\Mydocs\\" (Get-Credential) -Directory











RELATED LINKS