forked from dsccommunity/xPSDesiredStateConfiguration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xFileUpload_UploadToSMBShareConfig.ps1
88 lines (74 loc) · 2.82 KB
/
xFileUpload_UploadToSMBShareConfig.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<#PSScriptInfo
.VERSION 1.0.1
.GUID 4b9e3719-034a-4f3e-aa48-321cc242fa9e
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT
.TAGS DSCConfiguration
.LICENSEURI https://github.com/dsccommunity/xPSDesiredStateConfiguration/blob/main/LICENSE
.PROJECTURI https://github.com/dsccommunity/xPSDesiredStateConfiguration
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES First version.
.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core
#>
#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
}
}
}