r/PowerShell • u/Tsonga87 • 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 :).
12
u/iguessicancontribute Jun 05 '18
Gratz! Be careful though. You may find yourself trying to use Powershell in more complicated and dangerous situations to get the same rush as before. Powershell appears to be a gateway to using more Powershell.
4
u/Polyolygon Jun 06 '18
Can confirm. I finished my first script last week. I canβt stop trying new things and showing my coworkers. Iβm going down the rabbit hole.
3
u/JohnC53 Jun 05 '18
That's kind of true... I get a little excited when new tasks get transferred to me, so I have a new challenge to create a better system, with more automation.
1
5
u/MrEpiX Jun 05 '18
Good work, nice seeing the start of a PowerShell fan! Best way to learn is always to find things you'd like to try solving that are bothersome or impossible to do manually.
3
Jun 05 '18
Way to go! As soon as the bosses notice your scripting they will want to see if you can automate a few things for sure.
3
u/g33rbox Jun 05 '18
Well done man!!! Best shit ever. I get so stressed now when I have to click things π
3
2
u/dus0922 Jun 05 '18
Although not my first script I did something similar today. I had to change a scheduled reboot for something like 15 servers . After a quick Google, and a for each Loop I had them all changed in a matter of seconds instead of having to manually go into each server and click a hundred different things...
2
u/Lee_Dailey [grin] Jun 05 '18
howdy Tsonga87,
that is one of the nifty things about coding ... creating something that does what you intend - and does it cleanly.
may many felicitations be yours! [grin]
take care,
lee
4
2
u/JBear_Alpha Jun 05 '18
I hear people talk about the time spent/time saved curve all the time but, because I've spent the time to write and research so much in the past pretty much everything writes itself 95%+ from my previous code.
I can't count the number of hours I've saved myself and my team from hand-jamming massive amount of bullshit. Keep going man, it's 150% worth it.
2
u/Flkdnt Jun 06 '18
No fucking ideas how I used to deal with shit pre-powershell
3
2
1
29
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
10
u/Suihaki Jun 05 '18
Hell yeah! Nice work! I remember my first script that worked a few years ago. Truly the most satisfying feeling is being able to do something without actually doing anything!
I'll leave the words my coworker that introduced me to PowerShell said to me when I started making scripts. They have turned into my mantra.
"If you have to do it more than once, you might as well script it."
Cheers bud!