I have my question regarding App-v 5.0 SpX script execution (Powershell).
1. AddPackage - When the script is placed in Addpackage script type, it gets executed when the App-V package is added or registered to the machine. It gets executed when running the below command.
Add-AppvClientPackage "name" -DynamicDeploymentConfiguration "path to the deploymentconfig.xml"
PublishPackage - The script gets executed when the package is being published to the machine during Publish-AppvClientPackage event.
deploymentconfig.xml file can be used along with the Add-AppvClientPackage only. Userconfig.xml can be used along with Publish-AppvClientPackage only.If package is being published global using -global, Userconfig.xml cannot be used only deploymentconfig.xml can be used.
2.And coming to script to copy the files to %userprofile%, I guess you would have kept the script to run in systemcontext(machineconfiguration in DeploymentConfig.xml) that's what it has failed. Keep it in the Userconfiguration (Sourcesection)- Publishpackage (script type) section inside the DeploymentConfig.xml. This would run the script in user context so that %userprofile% entries are populated.
NOTE: If you keep script in UserConfiguration section, then it should be tested only in domain joined machines. It will not work in local account.