Forgive the formatting, first post:
The scenario: When deploying an SCCM app under the system context, I wanted to be able to copy a license file to the logged-on user’s appdata folder.
The Result:
#Copy license file to user
$User = $($CurrentLoggedOnUserSession.Username)
Write-Log -Message “User Targeted for Install: $User” -Source ‘Target-User’ -LogType ‘CMTrace’
$Paths = Get-UserProfiles | Select-Object -ExpandProperty ‘ProfilePath’
foreach ($Path in $Paths) {
if ($Path -match $User) {
Write-Log -Message “Targeted User Profile: $Path” -Source ‘Target-User’ -LogType ‘CMTrace’
Robocopy “$dirSupportFiles” “$path\appdata\roaming<appfolder>” license.xml
}
}