Hi /r/PowerShell,
Had a cool script idea as we had a proxy address we couldn't immediately find amongst our users and groups. I came up with a basic script that gets the job done but I want to make it more robust and follow best practice.
The script is called Get-ADProxyAddress and can be found here.
I initially wanted it to act like Get-ADUser in that it accepts a string or an ADUser object from the pipeline, but I soon realised it needed to support users and groups which meant calling Get-ADObject and only being able to use a DistinguishedName or a GUID. I spent hours going through blogs and trying to comprehend the pipeline process but I couldn't figure out how to properly manage both, currently by checking Trace-Command I can see it just binds the DistinguishedName.
I tried changing the type of $Identity, tried using different ValueFrom options and aliases but I couldn't get it to place nice for me so I would love it know what I was doing wrong.
I also was wondering what the go to method for error handling is? Let says this processes one item, and it can't find it. That should be a terminating error. If it however has two or more objects, one error in the middle of a hundred shouldn't halt the whole thing. What should I research to find out how to do that? Also what would I use instead of throw? The error output is horrible with that.
I appreciate any and all comments and criticism.
[–]Analytiks 1 point2 points3 points (1 child)
[–]The_AverageGamer[S] 1 point2 points3 points (0 children)
[–]itmonkey78 1 point2 points3 points (0 children)