The Surly Admin

Father, husband, IT Pro, cancer survivor

Read Text Files Faster than Get-Content

This was a fun little script I threw together after a particular conversation came up at Spiceworks.  If you’ve worked with PowerShell long you’ve used Get-Content to read a file.  99% of the time, it’s fine and you just continue on with life.  This blog post is about that 1% when Get-Content is SLOW.  The .NET IO.Streamreader is where people turn to speed things up so I decided to create a  function around it that worked much like Get-Content does.  This is it’s story.

Continue reading

Advertisements

June 1, 2015 Posted by | Powershell - Performance | , , , | Leave a comment

Setting the Manager Field in Active Directory

One thing I like to do in Active Directory is set the Manager field. To be honest, I’m not sure why I do this because we’re not using it, it’s just something I do. I guess you could call it future proofing. But there is a problem with this and that’s what do you do when a Manager leaves the company? There’s no easy way to pick up their direct reports and transfer them to a new manager. Until now.

Continue reading

February 18, 2013 Posted by | PowerShell | , , , , | 15 Comments

More Advanced Functions

Want to add some more functionality to our scripts and functions?  Want your scripts to operate like the standard Powershell cmdlet’s, with the same Common Parameters?  Well you can, and it’s not difficult at all.  Read on to add these abilities to your scripts!

Continue reading

February 11, 2013 Posted by | PowerShell | , , , | 3 Comments

Functions That Use the Pipeline

Earlier this week I talked about creating HTML reports from within Powershell, using the ConvertTo-HTML cmdlet.  One of the technique’s I used was a custom function I wrote called Set-AlternatingRows which took the table created by ConvertTo-HTML and alternated the row colors.  This was a great exercise in using Functions and the Pipeline and I wanted to talk about that today.

Continue reading

January 24, 2013 Posted by | PowerShell | , , | 7 Comments

Functions – When and how?

Recently I was reworking a script for someone at Spiceworks, you can read about it here.  But some interesting things came up and I wanted to talk about it here.  It’s about functions, and when and how you should use them.  Read on to hear my take on the subject.

Continue reading

January 3, 2013 Posted by | Powershell - Best Practices | , | 3 Comments