Categories
Welcome Center
Education & Development
Cyber Security
Virtualization
General
Certification Preparation
Project Management
Posts
Groups
Training Resources
Infosec
IT & Security Bootcamps
Practice Exams
Security Awareness Training
About Us
Home
Discussions
Off Topic
Oh Powershell...
the_Grinch
Loving Powershell more and more every time I use it. A few weeks ago I wrote a script to go to a website, copy the text into a text file, and then convert the text file to a csv. From there (for now anyway) I copy a column into a master spreadsheet to compare values to look for changes. Now this script has literally worked for two weeks without issue and then suddenly (on the page with the largest amount of text) it starts to fail. I started to manually copy the text since I didn't have time to troubleshoot, but today I swore to fix it. Started reviewing the output and saw that it was timing out on the one page. In a manual test I saw it takes about two minutes to load so I tried a manual pause, but it didn't work.
So I Google "invoke-webrequest timing out" only to low and behold find out there is a timeout option for it! Entered in -TimeoutSec 120 and it's working without a hitch once again!
Find more posts tagged with
Comments
cgrimaldo
I really want to learn powershell...Threads like these remind me I need to do that..
DevilWAH
I love that feeling when a job that to manual carry out takes 2 hours, but after a few hours toying with a scrip, you hit the return key and seconds later it completes perfectly, and you know never again will you have to do it the long way.
I still have a soft spot for one of my fist scripts, which took a list of switch/port/vlan/speed/duplex.
sorted them in to order by switch, logged on to the first switch, checked the current configuration and status of the port and saved the information, applied the new standard config from the list of valules, rechecked the port status, if it had changed then rolled back the config, or if it was acceptable saved the new config, and then either moved on to the next port or saved the config and logged of. Then once it go to the end of the list created a report with which port had passed or failed.
On average it could do about 900 ports in 15min, compared to the best part of 4 hours to do by hand, and it never made mistakes like configuring the wrong port, or atering the config of a port currently connected.
Mine you that was in VBa
the_Grinch
Devil that is awesome! I'm definitely falling more into scripting and it is great. Once we start our Nagios setup, it's really going to get big!
NotHackingYou
Scripting leads to Automation. Automation leads to coding. And coding leads to the dark side...
Welcome!!!
Crikey
Having spent some time using VB scripting, I can say without a doubt that Microsoft actually did something right with PS.
lsud00d
The ol' invoke-restmethod eh?
It helps coming from a linux background moving to PoSH...For instance in this case I would think "how can I
w
get or curl?" and then find the PoSH equivalent. It helps that many of the commands are linux aliased but I've been trying to break that habit and learn the PoSH syntax of the command.
Architect192
Same here... Been dabbling with PS for a while but nothing serious. In my current mandate we needed to reconfigure 200 VMs that had e1000 adapters to VMXNET3. I wasn't about to ask the sysadmins to do it manually so I wrote a script that goes through the whole process.
- Get the current IP information
- shutdown the VM
- change the adapter type (retaining the mac address)
- set the "update vmware tools at startup" while at it
- start the VM
- purge the ghost devices
- rename the network connection
- update the IP information, disable IPv6 (their requirements...), setup some specific network parameters etc...
- reboot the machine one last time.
All this? One simple command line. ReconfigVM "vmname"
oh and if you specify a cluster, it processes all the VMs in the cluster.
Really fun stuff to do.
Right now I'm working on basic scripts to do the initial configs I do on servers after installation that I can't put in the template. Would even work on physical systems
Fun stuff! hardest part is to figure out what do to, not how to do it...
the_Grinch
I love automation! Much less room for error and I can setup the scripts to run without me being there (a big plus). Great hearing all the stories from the trenches!
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of