Avatar of robertarenson
robertarenson

asked on 

Powershell Assistance

I am trying to copy over a file in the root of C:\Citrix\Profiles.v2 to every users profile location but I keep running into errors.  Was hoping that someone might have a better way of making this work.

Thanks again

Script:

# Variables
$users= Get-Childitem "c:\users" | Select-Object -Property name

Foreach ($user in $users) {
   
    #Verify The profiles Directory Exists
    $path = test-path "c:\users\$user\AppData\LocalLow\Sun Java\Test"
   
    # If $path = True (Implied True in the below statement)
    if ($path) {
       
        $profiles=Get-ChildItem "c:\users\$user\AppData\LocalLow\Sun Java\Test" | select-object name

         Foreach ($ffprofile in $profiles){
           
            $ffox = "c:\users\$user\AppData\LocalLow\Sun Java\Test\test.txt"

            #Test the Path
            $path = Test-Path $ffox
       
            # If $path = True (Implied True in the below statement)
            if ($path) {
                Copy-item "C:\Citrix\Profiles.v2\Sun Java\Test\Test.txt" -Destination "c:\users\$user\AppData\LocalLow\Sun Java\Test\$ffprofile" -Force
                write-host "User: $user"
                Write-host "Profile: $ffprofile"
            }
        }
    }
}
Windows Server 2008Powershell

Avatar of undefined
Last Comment
Spike99
ASKER CERTIFIED SOLUTION
Avatar of James Rankin
James Rankin
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

And rather than just saying "I keep getting errors"
Say what the errors are. Show what efforts you have made to debug the errors. Paste a screen shot.
Avatar of Spike99
Spike99
Flag of United States of America image

Although, you didn't specify the errors you were seeing, I suspect it's not working because Admins lack rights to the users' profile folders by default, Admins do not normally have access to user profile folders unless you enable this group policy setting BEFORE those folders were created:
Configuration/Policies/Administrative Templates/System/User Profiles
“Add the Administrators security group to the roaming user profile.”

So, if that's the case, it might be better to reconfigure the script to be run by the user & have it run as a logon script for all users so the file can be copied to the user's profile folder using their own creds (they would have full rights to copy files to that  folder in their roaming profile folder).  Just make sure the source file is in a location on the network that they at least have read access to.
Windows Server 2008
Windows Server 2008

Windows Server 2008 and Windows Server 2008 R2, based on the Microsoft Vista codebase, is the last 32-bit server operating system released by Microsoft. It has a number of versions, including including Foundation, Standard, Enterprise, Datacenter, Web, HPC Server, Itanium and Storage; new features included server core installation and Hyper-V.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo