An extra
Get-ChildItem
/
ForEach-Object
should work, with an added
Test-Path
to exclude folders which don't exist:
$source = 'C:\Program Files\Mozilla Firefox\plugins\plugin.xpi'
Get-ChildItem "C:\Users" -Directory | Where-Object { Test-Path "$($_.FullName)\AppData\Roaming\Mozilla\Firefox\Profiles" } | ForEach-Object { Get-ChildItem "$($_.FullName)\AppData\Roaming\Mozilla\Firefox\Profiles" -Directory } | Where-Object { Test-Path "$($_.FullName)\extensions" } | ForEach-Object { Copy-Item $source -Destination "$($_.FullName)\extensions" -Verbose }
Get-ChildItem "C:\Users" -Directory
lists the directories under the Users folder;Where-Object { Test-Path "$($_.FullName)\AppData\Roaming\Mozilla\Firefox\Profiles" }
filters to user folders with a Firefox profile;ForEach-Object { Get-ChildItem "$($_.FullName)\AppData\Roaming\Mozilla\Firefox\Profiles" -Directory }
lists the folders under each Firefox profile;Where-Object { Test-Path "$($_.FullName)\extensions" }
filters to profile folders with an "extensions" sub-folder;ForEach-Object { Copy-Item $source -Destination "$($_.FullName)\extensions" -Verbose }
copies the source to the extensions folder