Powershell: Dirty workaround to copy files to current user profile

posted in: Blog, Powershell | 2

Powershell Logo

It’s always quite a hassle if you want to copy a file to the current User Profile, if you are running a script via Configuration Manager, as the script is run in System context. Another way of going around this issue is to set “Install as User” for the Deployment Type. This is however only possible if you are installing an Application and the user also needs to be a local admin on the machine, which in most cases is not permitted.

If you want to copy files to the currently logged on user, you can use this workaround. This will copy the file to all User profiles, except for the Public one. This works great if only one person logs in to the computer, but might not work well if more than one person logs in, as the file will be copied to all profiles in C:\Users.

2 Responses

  1. Visokoo

    Thanks for this. Saved me a lot of time.
    Instead of Copy-File, do you mean to type Copy-Item?

  2. No worries and thanks for the input. Yes, it should have been Copy-Item. Fixed it 🙂

Leave a Reply