I am working on a PS script to send all the users in our AD, who will need to reset their password in the upcoming days, an info e-mail. The script does the job quite good, but i want to limit the target users to members of a certain security group.
I would like to additionally filter to only get users from the security group “SendMail”. I tried it with get-ADGroupMember but i was not able to add this additional cmdlet to the current script and get it to work.
Hi Olaf and thank you very much for your fast and useful response! I will keep that splatting thing in mind. Since i am quite new to powershell (and scripting as a whole) i can really use tips like that.
It is now possible to fill the array with the members of the group. However, this brings me to a new problem. After filling the $users the next part is this:
Oooops … my mistake … I didn’t pay attention to that at first … I updated my code example above.
You could do me a favor: Try to reduce the use of white space while posting and format code as code using the code tag button (“pre”) on the icon bar of the post editor. That makes it more readable and in case of code it prevents unwnated line breaks and makes it easier to copy and puts a little syntax highlighting to it.