# Copy Item to All User Profiles

**URL:** <https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785>\
**Category:** PowerShell Help\
**Created:** [November 29, 2017, 4:08pm UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785 "2017-11-29T16:08:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![btorvick](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@btorvick](https://forums.powershell.org/u/btorvick)\
**Post date:** [November 29, 2017, 4:08pm UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/1 "2017-11-29T16:08:39Z")

</div>

Greetings,

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 (  
[Parameter(Mandatory=$true)][string]$computername,  
[Parameter(Mandatory=$true)][string]$username  
)

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?

Thanks,

-Brandon

---

<div class="post-metadata">

**Author:** ![random-commandline](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@random-commandline](https://forums.powershell.org/u/random-commandline)\
**Post date:** [November 29, 2017, 9:04pm UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/2 "2017-11-29T21:04:44Z")

</div>

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
}
```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 30, 2017, 1:36am UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/3 "2017-11-30T01:36:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![btorvick](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@btorvick](https://forums.powershell.org/u/btorvick)\
**Post date:** [November 30, 2017, 9:13am UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/4 "2017-11-30T09:13:35Z")

</div>

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…

Thanks,

-Brandon

---

<div class="post-metadata">

**Author:** ![btorvick](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@btorvick](https://forums.powershell.org/u/btorvick)\
**Post date:** [November 30, 2017, 9:26am UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/5 "2017-11-30T09:26:51Z")

</div>

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!

Thanks,

-Brandon

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:37pm UTC](https://forums.powershell.org/t/copy-item-to-all-user-profiles/9785/6 "2024-05-16T20:37:08Z")

</div>

Closed on May 16, 2024, 8:37pm UTC


