PowerShell bulk copy and remove file $Computers

BULK COPY

$Computerlist = Get-Content  C:\Scripts\Computers.txt

foreach ($Computer in $Computerlist) {

Copy-Item -Path \\share\Install\test.txt -Destination \\$Computer\c$ -Recurse -PassThru

}

BULK REMOVE

$Computerlist = Get-Content  C:\Scripts\Computers.txt

foreach ($Computer in $Computerlist) {

Get-ChildItem -Path \\$Computer\c$\test.txt | Remove-Item -Force

}

Leave a comment