Solved

Copy one file to multiple subfolders by Powershell

Posted on 2013-06-13
4
1,340 Views
Last Modified: 2014-09-30
Hello

I am new to powershell and has gone a bit cold for something that I thought was simple.

We use Microsoft Server 2012 RDS for terminal clients. where we use a "dummy user" to create a default Metro tiles start menu.

When we make changes in the start menu, I want the appsFolder.itemdata-ms  file Copied to all user profiles at night when they are offline.

so i need a powershell script there can copy one file from a folder to all subfolders in another folder.
is there a way to do this without the need to list all the subfolders by name. They change all the time

something like "copy \\server1 \ profiles \ username.domain.V2 \ appsFolder.itemdata-ms to \\server2 \ profiles \" all folders "?
0
Comment
Question by:CyruzQ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39243774
Get-ChildItem -Path \\server2\profiles | ?{ $_.PSIsContainer } | Copy-Item '\\server1\profiles\username.domain.V2\appsFolder.itemdata-ms' -Destination $_.fullname

Open in new window

0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 39297470
That works, but only with PS 3. If you want to execute it with PS 2:
Get-ChildItem \\server2\profiles | ? { $_.PsIsContainer } | select @{l='Destination'; e={$_.FullName}} | copy-item -Path '\\server1\profiles\username.domain.V2\appsFolder.itemdata-ms'

Open in new window

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question