Copy a File to a Folder in a User's Profile

I generated this worklet for a customer that wanted to take a text file called “signin.slacktoken” with a Slack token in it and have it copied to users’ Download directory. For your purposes, upload the file you want to be copied and set the $uploadfile variable in the evaluation and remediation to be exactly equal to the name of the uploaded file. Then just set the location you want the file in evaluation and remediation.

Evaluation:

# Set variable to the exact name of the installation file uploaded
$uploadfile = 'signin.slacktoken'

# Sets current user
$currentusr = (Get-WmiObject -class win32_process -ComputerName 'localhost' | Where-Object name -Match explorer).getowner().user

# Check to see if the file exists in the user's profile location where it should be saved.  If so, exit with no action.
if (Test-Path -Path "c:\Users\$currentusr\Downloads\$uploadfile") {
	exit 0
} else { Exit 1 }

Remediation:

# Set variable to the exact name of the installation file uploaded
$uploadfile = 'signin.slacktoken'

# Sets current user
$currentusr = (Get-WmiObject -class win32_process -ComputerName 'localhost' | Where-Object name -Match explorer).getowner().user

# Copy the installation file uploaded to the desired location in the user's profile.  In this example it's the user's Downloads folder.
Copy-Item $uploadfile -Destination "c:\Users\$currentusr\Downloads\$uploadfile"

Thanks I’ll give this a try