-
Notifications
You must be signed in to change notification settings - Fork 134
xFileUpload
dscbot edited this page Nov 11, 2023
·
1 revision
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
DestinationPath | Required | System.String | The destination SMB share path to upload the file or folder to. | |
SourcePath | Required | System.String | The source path of the file or folder to upload. | |
Credential | Write | System.Management.Automation.PSCredential | Credentials to access the destination SMB share path where file | |
or folder should be uploaded. | ||||
CertificateThumbprint | Write | System.String | Thumbprint of the certificate which should be used for encryption/decryption. |
Provides a mechanism to configure and manage multiple xGroup resources with common settings but different names
#Requires -Module xPSDesiredStateConfiguration
<#
.SYNOPSIS
Configuration that uploads file or folder to a SMB share.
.DESCRIPTION
Configuration that uploads file or folder to a SMB share.
.PARAMETER DestinationPath
The destination SMB share to upload to. It must be the root of the SMB
share or an existing folder under the SMB share,
e.g. '\\MachineName\ShareName\DestinationFolder'.
.PARAMETER SourcePath
The source file or folder to upload, e.g. 'C:\Folder' or
'C:\Folder\file.txt'.
.PARAMETER Credential
Credentials to access the SMB share where file or folder should be
uploaded.
.PARAMETER CertificateThumbprint
Thumbprint of the certificate which should be used for encryption and
decryption of the password. The certificate must already exist on the
target node in the machine personal store ('cert:\LocalMachine\My').
This parameter must be provided if the Credential parameter is provided.
.EXAMPLE
xFileUpload_UploadToSMBShareConfig -DestinationPath '\\MachineName\Folder' -SourcePath 'C:\Folder\file.txt' -Credential (Get-Credential) -CertificateThumbprint 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Compiles a configuration that uploads the file 'C:\Folder\file.txt' to
the root od the SMB share '\\MachineName\Folder', and uses the thumbprint
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' to encrypt and decrypt the
password of the credentials, the credential is used to log in to the
SMB share.
#>
Configuration xFileUpload_UploadToSMBShareConfig
{
param
(
[Parameter(Mandatory = $true)]
[System.String]
$DestinationPath,
[Parameter(Mandatory = $true)]
[System.String]
$SourcePath,
[Parameter()]
[System.Management.Automation.PSCredential]
$Credential,
[Parameter()]
[System.String]
$CertificateThumbprint
)
Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'
Node localhost
{
xFileUpload fileUpload
{
DestinationPath = $DestinationPath
SourcePath = $SourcePath
Credential = $Credential
CertificateThumbprint = $CertificateThumbprint
}
}
}