Solved

Copy one file to multiple subfolders by Powershell

Posted on 2013-06-13
4
1,175 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
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 68

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now