-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUploadLocalFiles.ps1
More file actions
34 lines (26 loc) · 1.5 KB
/
UploadLocalFiles.ps1
File metadata and controls
34 lines (26 loc) · 1.5 KB
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
Import-Module ShareFile
#Import-Module ShareFile-Core # For PowerShell 7+
################################################################################
# UploadLocalFiles.ps1
#
# This script will upload all files in the local Documents directory to the
# My Files and Folders area of ShareFile.
#
# Note: The ShareFile location needs to be specified as files cannot be written
# to the root of the account. This script gets the user's home folder and
# uses that, but shared folders could also be used.
#
#Run the following interactively to create a login token that can be used by Get-SfClient in unattended scripts
#$sfClient = New-SfClient -Name ((Join-Path $env:USERPROFILE "Documents") + "\YourSubdomain.sfps") -Account YourSubdomain
$sfClient = Get-SfClient -Name ((Join-Path $env:USERPROFILE "Documents") + "\YourSubdomain.sfps")
#upload directory is relative to the root of the account
#get the current user's home folder to use as the starting point
$ShareFileHomeFolder = (Send-SfRequest $sfClient -Entity Items).Url
#use the local My Documents folder as source
$LocalPath = (Join-Path $env:USERPROFILE "Documents")
#Create a PowerShell provider for ShareFile at the location specified
New-PSDrive -Name sfDrive -PSProvider ShareFile -Client $sfClient -Root "\" -RootUri $ShareFilePath
#upload all the files (recursively) in the local folder to the specified folder in ShareFile
Copy-SfItem -Path $LocalPath -Destination "sfDrive:"
#Remove the PSProvider when we are done
Remove-PSDrive sfdrive