I try this function, but didnt have much success. The infos in the helpfile didnt helped me either.

what I want to do is simple.
Copy-File -Path "$dirSupportFiles\Config.xml" -Destination "$envAppData\Manufactor\Software\Config.xml"

This command I want to run in User Context, for that I try this function.
But the following code didnt work…
Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-noexit -Command & {Copy-File -Path '$dirSupportFiles\Config.xml' -Destination '$envAppData\Avaya\Avaya one-X Communicator\Config.xml'}" -RunLevel HighestAvailable -Wait -PassThru

I struggle with the -Command part, the rest seems clear to me.

Hope anyone has an idea for me.


I usually run this as SYSTEM. It will write the changes to default user as well, unless you exclude.

<code>[string[]]$ProfilePaths = Get-UserProfiles | Select-Object -ExpandProperty &#039;ProfilePath&#039;
ForEach ($ProfilePath in $ProfilePaths) {
       Copy-File -Path &quot;$dirSupportFiles\&lt;filename&gt;&quot; -Destination &quot;$ProfilePath\AppData\Roaming\&lt;folder path&gt;&quot; 

thanks a lot, it works :slight_smile:


Brian can you explain what the code does?
Does it execut the application installation with the System account, but retrieves the logged user and (for this example) copy the file into the %appdata% of the logged user?

Thank You,

The code as stated doesn’t state a: runas because this is ran with whatever credentials is used during the installation. All this code does it retrieve all user accounts on a machine and then runs what you want for each account. So this includes the logged on user because that account exists on the machine.