Powershell Copy Item
$RootDir = $PSScriptRoot
#wmic product where "name like 'Java 7%%' or name like 'Java 8%%'" call uninstall /nointeractive
# Install Java
Write-Host "Installing Java..."
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "jre1.8.0_161.msi") -ArgumentList "-qn" -Wait
# disable autoupdate
Write-Host "Disabling Java Update..."
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f
reg add "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f
# Copy File
Write-Host "Copying Files.."
Copy-Item -Path $RootDir\Deployment\*.* -Destination "$env:Userprofile\Appdata\LocalLow\Sun\Java\Deployment" -Force -Recurse
My code above works fine if i am running it from the powershell from the folder thats on the desktop. I have packaged it in the SCCM and calling the powershell via batch file. Half of the script works. It installs the Java, however it won't copy the file. If i go to C:\Windows\ccmcache\5 and run just the line from the powershell Copy-Item -Path $RootDir\Deployment\*.* -Destination "$env:Userprofile\Appdata\LocalLow\Sun\Java\Deployment" -Force -Recurse i get an error Cannot find path 'C:\Deployment' because it does not exist.
This leads me to beilve that last part of my script does not work when running as a SCCM package from C:\Windows\ccmcache\(whatever the folder it assigns it to)
How can i make copy portion to work from that folder?
My Folder Structure.