Your question is a bit vague ... sorry if that sounds rude for you but did you try to type this questions in your favorite search engine? SCCM comes with a specialized Powershell module and it's possible to achive what you're asking for but we cannot write your scripts for you. You should come back when you have a specific question about a particular issue you have with code you wrote.
Below code is regarding the Deployment Settings in SCCM. We have multiple deployments enable with setting "Always Re-Run" on multiple collections and we need to change that setting to "Failed if re-run" for all the deployments. Below code helps me to change that by changing the remoteclient Flag value. Now the bigger task is we need to change that on all the deployment which has "Always Re-run" and i am unable to build the loop. Please help me here :-