Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Copy two files into the profile

$
0
0

Hi there.I want to copya folderwith twofilesin the DFSShareinthe user'sCitrixprofile.However, if thefolderalready exists,nothing shouldbe copied.This shouldbechecked everytime the user logs.I wantthis scriptthen applyviaGPO.The20 users areincluded in the group"Group1".They should besoalways check.
I have this codecopied fromanotherpost.I haveslightlyadaptedthis code.But he isnot by mebutby JaapBrasser.Thanks for that

$Path='\\Domain\private\Prog1'#Root path to look for files
$DestinationPath="C:\user\%username%\"

#Grab a recursive list of all subfolders
$SubFolders= dir $Path-Recurse | Where-Object {$_.PSIsContainer} | ForEach-Object-Process {$_.FullName}

#Iterate through the list of subfolders and grab the first file in each
ForEach ($Folderin$SubFolders) {
$FullFileName= dir $Folder | Where-Object {!$_.PSIsContainer} | Sort-Object {$_.LastWriteTime} -Descending | Select-Object-First 1
Copy-Item-Path$FullFileName-Destination$DestinationPath-Force
}

The background:
I havepublishedan application usingApp-V.
However, thisrequiresan ini-file and anmdbfile in thec:\user\%username%folderto use this feature.When I copythe folderwith the twofiles manually, everything works.However, when Iprofileexampleputbackin 6 months, I stillhave to think ofthe folder.I want toautomate this.
Thank you


Viewing all articles
Browse latest Browse all 6937

Trending Articles