Sorting help, I think I’m very close

Hi everyone, I’ve been pushing to learn more about powershell and I’m still learning. I was hoping that someone could review the following code and check out line 6 to see if I’m writing this correctly because I’m having issues with it running. If I remove my command, | Sort-Object Name, then everything runs normally. However when I try to get the script to pull from AD and sort by last name (I really don’t care if it’s ascending or descending) then the script fails. My only points of reference are this page and Microsofts powershell page which is surprisingly pretty good.

If I’m doing this wrong can someone help me and tell me what I am doing wrong and how I should write this one little bit of code out?

https://pastebin.com/AHPEyPpR

submitted by /u/escapednut
[link] [comments]

Leave a Reply