troubleshooting Question

Powershell Assistance

Avatar of robertarenson
robertarenson asked on
PowershellWindows Server 2008
3 Comments1 Solution57 ViewsLast Modified:
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"
            }
        }
    }
}
ASKER CERTIFIED SOLUTION
James Rankin
Media Hound

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros