$ Source = "C: \ windows \ system32 \ windowspowershell \ V1.0 \ modules \ carbon "$ target =" \ C $ \ windows \ system32 \ windowspowershell \ V1.0 \ modules "$ on_off = import-CSV-Path' c: \ aaa.csv '| select IPaddress, fulldomainname, @ {name = 'on _ off'; expression = {test-path ("\" + $ _. IPaddress + $ target) }# determine whether the target folder is valid $ on = $ on_off | where on_off-EQ $ true $ on | export-CSV-path C: \ aaa-ON.csv-Force $ off = $ on_off | where on_off-EQ $ false $ off | export-CSV-path C: \ aaa-OFF.csv-force # Save valid and invalid objects $ on | where {(test-path ("\" + $ _. IPaddress + $ target + "\ carbon")-EQ $ false} | foreach-object {copy-item-path $ source-destination ("\" + $ _. IPaddress + $ target)-recurse-force} # Find the host without the carbon folder (that is, it has not copied carbon) and Start copying
Copy the folder to the remote host in the list