Learn some good shell scripting. Take a look at this script. This guy uses about every shell command there is. Maybe not every single one, but most of the useful commands like “for” and various search and find commands. Gold, pure gold scripting.
https://gallery.technet.microsoft.com/scriptcenter/Reset-Windows-Update-Agent-d824badc