Copy Item to All User Profiles


I am not only new around here, but new to PowerShell and have been enjoying the community and learning experience, thus far. I am hoping somebody here can assist! I have been musing around how to copy an XML file from Roaming\AppData in the user profile to all domain users that have logged into the PC, but I am not having much luck. Hoping I could get some help with this and learn something in the process.

This works to prompt for computer name and copies the file, but only for one user (again, I need all user profiles on the machine to get this file) :

Param (

Copy-Item -LiteralPath C:\Users\btorvick\AppData\Roaming\SAP\Common\SAPUILandscape.xml -Destination \$computername\C$\Users$username\AppData\Roaming\SAP\Common -Verbose

I tried omitting $username, then using either *, %username%, or %userprofile% but no luck. I am close to figuring this out, or completely above my head here?



I don’t have my domain environment available; but off the top of my head, something like this should work after gathering computer accounts from Active Directory and combined with Invoke-Command.

$source = 'C:\Users\btorvick\AppData\Roaming\SAP\Common\SAPUILandscape.xml'

Get-ChildItem C:\Users | ForEach-Object {
    Copy-Item -LiteralPath $source -Destination "$($_.FullName)\AppData\Roaming\SAP\Common" -Verbose

Sounds for me like a perfect task for a Group Policy, don’t you think?

Hi “Random Commandline” – thanks for taking the time to think about this, I appreciate the input.

On the real, I am only following you about half-way on what you wrote and suggested above. As I mentioned in the original post, I am really new to PS and working through the basics. Can you clarify more on what you mean by gathering AD computer with the Invoke cmd?

The way I am thinking about it, is to create a CSV with a header and computers names to run the script against…



Hi Olaf –

To provide a bit of context here… Technically this should be done with an SAP Gui Installation server through a custom package build, not through GPO or PS. Our Basis Admin is not able to work on this, leaving me to pick up the pieces; trying to find a “dirty” means to an end. Ultimately, yes, I could put up a GPO policy but I find the value in learning how to do this is PS as GPO’s aren’t always the right answer.

Figured this is a great to forum to inquire!