This script is a direct replica of the script which has been posted by Eshwar Koneti a year back. I have just tweaked it according to my needs. Hope this could be helpful for others too.
So I had a requirement of creating a script which would check for server roles and features everytime prior to installing DP. Now for multiple servers, it would be really hard to check even if the Server is built by your TS. So, I had to create a script which would check the server roles and features required for installing Distribution Point. We also added later the part to inject my DP to the specific group and provide local admin rights to Primary site server account if not already added. this can be done in 2 simple lines but I removed them from this script as you may not have the right to do these on DP servers.
The script DPInstall.ps1 is plain and simple Eshwar's script from the below blog:
I just added one more script and called it inside his script that would check the roles and features. So actually it performs three tasks now.
1. It checks and installs the Server roles and features if required.
2. It checks whether the server you mentioned exists and DP is already there on it, if it has it will exit and no longer execute.
3. If everything is ok it will install DP fine and then generate a log.
Hope this helps you and I am very much thankful to Eshwar for sharing his work with us which helped me a lot.