r/PowerShell • • Jun 05 '18

Made my first script today!

Although I have been using other peoples scripts, and editing as needed, I have always avoided taking the plunge with PowerShell.

But today.......today I made my own script and it worked! It was pretty simple and only counted the number of objects in three AD security groups and then moved them into different security groups (and took additional AD creds), but it worked!

Happy!

Edit: Thanks for the comments, guys! What is even cooler is that I have just had to use a variation of the same script again. All the work this morning even paying off this afternoon.

Edit 2: Thanks again for all the positive feedback! I am going to comment my script and keep it safe :).

126 Upvotes

28 comments sorted by

View all comments

29

u/[deleted] Jun 05 '18

[removed] — view removed comment

8

u/rhilterbrant Jun 05 '18

Oh, I've got this! I saved my credentials into an encrypted file, then created a script that will connect to O365 and supply those credentials. It then removes User X's ownership permissions from Users A, B, and C's calendars, then it reapplies them. In a previous iteration it would email me a list of everyone who had ownership to Users A, B, and C's calendars. It does this every night.

6

u/Steev182 Jun 05 '18

There must be a reason for this.

13

u/rhilterbrant Jun 05 '18

"I dont have permission to add things to their calendar! Fix it!"

"Yes you do. I just tested it."

"Well it doesn't work!"

So I would just remove permissions, re-add permissions, and show them a print off showing that they had ownership. Thus the email.

8

u/Steev182 Jun 05 '18

See! It has a point :D Bloody users...