Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Scripting file replacement across local profiles

$
0
0
Hello,

I’ve run into a snag and I hope someone can assist. Here’s the short version…

1. Grab all users on a workstation
2. For each user, check for folder path
3. If the path exists, check for multiple folders in that path and replace a file within each one

Easy enough right? Not so much… here is what i have so far

#><# Variables #>
$users= Get-Childitem "c:\users" | Select-Object -Property name 
$profiles=Get-ChildItem "c:\users\$user\AppData\Roaming\Mozilla\Firefox\Profiles" | select-object name
$ffox = "c:\users\$user\AppData\Roaming\Mozilla\Firefox\Profiles\*\secmod.db"

Foreach ($user in $users)

{
    $profiles=Get-ChildItem "c:\users\$user\AppData\Roaming\Mozilla\Firefox\Profiles" | select-object name
            Foreach ($profile in $profiles){
                if ((Test-Path $ffox) -eq $true)
                    {Copy-item "\\networkshare.fq.dn\c$\directory\file.txt" -Destination "\AppData\Roaming\Mozilla\Firefox\Profiles\$ffprofile" -Force 
                         write-host $user $ffprofile}
    }
}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>