Update Save-InfoToAD.ps1

Updated with pulling out a large block of code to a private function. Also generalized the code for nearly all use cases.