New to PSADT - Copy files from the server to user directory

Hi all,

Please assist as this my first time trying PSADT

All I want is to copy files from server to user folder and install certificate.

I have modified the ## <Perform Installation tasks here> section with the script below.

        ## <Perform Installation tasks here>

        #Setting source path for CATIA

$Source = "\\SERVERIP\Applications\Dassault Systemes\DirectAccessCS2_202308241000\*"

#Getting current logged on user
$User = (Get-ChildItem Env:\USERNAME).Value

#Setting destination path for CATIA
$Destination = 'C:\users\' + $User + '\CATIA_V5_DMU'

#Copying from source to destination
Copy-Item -Path $Source -Destination $Destination -Recur -Force


#Adding certificates to the root store
certutil -addstore -f "root" "\\serverip\Applications\Dassault Systemes\DirectAccessCS2_202308241000\prod-bundle.p7b"

Do I just need this and deploy with SCCM with the following parameter ? Thanks.

"Deploy-Application.exe" -deploymenttype 'Install' -deploymode 'Silent'

One question that springs to mind is in which context are you deploying this (User or SYSTEM)?
If as the user - Do your users have permission to access the share ($Source)?
If as SYSTEM - The System account will not likely have access to the share ($Source) - Unless your folder permissions are very open (“Weak security”), also if it is run as System the $User and $Destination variables will not contain valid paths

I would suggest changing your $Destination line to:

$Destination = "C:\users\$($User)\CATIA_V5_DMU"

As this would likely cause less errors in the path due to unusual characters contained within the Username
and amend your Copy line (-Recur becomes -Recurse):

Copy-Item -Path $Source -Destination $Destination -Recurse -Force

Assuming this then works correctly, you will have just copied the entirety of the $Source to the $Destination, So the certutil command could then be modified to install the prod-bundle.p7b from the local copy in the $Destination folder, this way there should be no risk of a network interruption preventing this cert being installed.
You could even check it exists before attempting to install it
e.g.

If (Test-Path "$($Destination)\prod-bundle.p7b") {
    certutil -addstore -f "root" "$($Destination)\prod-bundle.p7b"
} else {
    Write-Log "WARNING :: Unable to find file `"$($Destination)\prod-bundle.p7b"`"
}
1 Like