RSS

Tag Archives: Scripting

Powershell – Recording of ‘The Case for PowerShell: Why To Learn-PowerShell So You Needn’t Leave-Industry’

Last week Mark Minasi presented a webinar made possible by http://www.learnit.com called:
“The Case for PowerShell: Why To Learn-PowerShell So You Needn’t Leave-Industry”.
The recording can be found here.

In this webinar he explains why ICT administrators need to be(come) familiar with PowerShell. He also explains the basic principles of PowerShell to help lower the threshold for people that have been shying away from command line interfaces (CLI) and scripting in the past. He does this by explaining how PowerShell is different from by example the CLI and Visual Basic Scripting (VBS).

I share his opinion about the necessity to learn PowerShell and therefore I hope I can help spread the message.

You can keep track of Mark Minasi by following him at Twitter: https://twitter.com/mminasi (@mminasi).

 
Leave a comment

Posted by on September 11, 2013 in Uncategorized

 

Tags: , , , , , , , , , , , , , , , ,

PowerShell – Reverse strings and reverse file names

With PowerShell it is relatively easy to reverse a string:
$str = “gnirtsdesrever”
$str[-1..-($str.length)] -join “”

Some of you might ask: Why would anyone want to do this ? Well, since the start of the year Usenet DMCA takedowns have begun to occur automatically, very quickly and very often. This means many movies and TV series on Usenet / News Groups are being taken offline very quickly.

Counter measures to prevent takedowns by uploaders include:

  • The use of encrypted links to NZB files.
  • The use file names that make it harder to find copyrighted files.

As you can probably guess, some just reverse the file names. The PowerShell script I’ve created will automate reversing the file names for files in the specified folder that match the specified file name filter.

I hope it is useful for you as well.

PS: Someone else on usenet had the same idea as me and created a VBS that will add a right-click menu option to explorer. I’ve added this in the same location as my PowerShell script as well.

 

Tags: , , , , , , ,

PowerShell – Cleaning folders containing temporary files

At the companies I’ve worked for , disk space on the system disk ran out on a regular basis for some systems and caused a lot of monitor calls. These kind of boring repetitive tasks are always the ones you want to automate.

So when I came across the great blog post “Weekend Scripter: Use PowerShell to Clean Out Temp Folders” on the “Hey, Scripting Guy! Blog”, I wanted to post it on my own blog as well. The blog post also describes the process of creating the script very well, which is very convenient for those who are relatively new to PowerShell to scripting and want to learn how to do it better.

If you want to take it even a step further, you could automate it even more. By example by automatically running the clean script when an event is generated that the disk is running out of space. You can configure this using by example:

Or you could use PowerShell remoting to do it on many systems at the same time. This could come in handy by example when after WSUS patching the content in “C:\Windows\SoftwareDistribution\Download” is not deleted automatically.

 

Tags: , , , , , , , , , , , , ,

VMware – PowerShell script to get (storage)vmotion history

Even though I’ve always liked VMWare vSphere, I thought the events and informational messages weren’t always as helpful as they could be.

One of the common things I want to know are the vmotions and storage vmotions that have taken place. Luc Dekens has created a great script that shows the (s)vmotions that have taken place including details about them.

Be sure to take a look at his website for the PowerShell / PowerCLI script including a detailed explanation:
http://www.lucd.info/2013/03/31/get-the-vmotionsvmotion-history/

 
 

Tags: , , , , , , , , ,

PowerShell – Book review of : Learn Windows PowerShell 3 in a month of lunches, second edition

About 6-7 years ago at school we were taught how to script using VBscript. I was really bad at it though and never really made an effort to change that. When PowerShell became more popular however I had gained some working experience and was also pleasantly surprised by the simplicity of it.

I started learning about PowerShell scripting by googling and using script examples. Disadvantages of this approach however is that:

  • You can pick up bad habits from others (without realizing it).
  • You sometimes don’t know exactly why you’re doing things a specific way.
  • You sometimes don’t know why some things are/aren’t working.

PowerShell is getting increasingly important though:

  • Even though more companies are offshoring and employees are relatively, it is still cheaper to automate instead.
  • Cost isn’t the only issue, speed is important as well. Scripting allows you to get things done more quickly.
  • PowerShell is increasingly being adopted by more companies, products and (cloud) services.
  • The number of available built-in cmdlets are increasing, which makes it even easier to automate actions.
  • For many products you have to use PowerShell to make specific settings, because only the more basic settings are available in a Graphical User Interface (GUI).
  • Changes can be applied consistently in a development, test, acceptance, pre-production, production environment.
    • Less chance of human error.
    • If done correctly, you’ll also have included a way to quickly revert the changes by script.

To make sure I didn’t miss out on too many things, I decided to start with a book that teaches the basics. Because of the good reputation of the authors Don Jones and Jefferey D. Hicks in the PowerShell community, I decided to go for their book “Learn Windows PowerShell 3 in a month of lunches, second edition” published by Manning Publications Co.

The book’s purposely didn’t try to stuff all PowerShell related information into the book. Instead it provided the reader/student with the basics needed to be able to find/discover this information themselves if needed. I personally like this approach, because otherwise there would be too much information to take in which might be demotivating and distracting.

I also liked the practical examples of common mistakes made by people who are new to PowerShell. There were a lot of examples I ran into as well when I started using PowerShell and I think this will prevent people from becoming frustrated because they understand why things aren’t working the way they might have expected.

All in all this is a great book to start learning PowerShell. This is however just the start and you should expect to continue using other resources/books to further your knowledge. The book also provides links to useful resources as well. And most importantly … start using PowerShell more so you will learn by experience.

Personally I still have these books lying around, but haven’t decided yet which one to start with next:

I’m also still considering taking a PowerShell course, but I’m a bit hesitant about the added value because it’s hard to determine the quality of a course by the description.

If you have experiences or suggestions, please let me know.

 
1 Comment

Posted by on February 27, 2013 in Automation, ICT, Microsoft, Powershell, Windows

 

Tags: , , , , , , , , ,

Powershell – Get Percentage of Pysical and Virtual Servers from your VMware and Cisco UCS combined for each location

In a previous blog post I’ve already shown this script that use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. This script however only took into account ESX hosts and VM’s in each Virtual Center server separately.

This means that:

  • The UCS blades weren’t taken into account as physical servers.
  • No percentage was being calculated for each physical location.

This new script automates determining for each location the number of physical and virtual servers in VMware vSphere and Cisco UCS.

PS: You can get more detailed information from the script, but it has been disabled using comments by default.

 

Tags: , , , , , , , , , , , , , , , , , , , , ,

PowerShell – Get UCS Blade Count

PowerShell has been adopted by many companies already including VMware and Cisco with its Unified Computing System (UCS).

This simple script will use the Cisco UCS PowerTool to connect to UCS and determine the blade count for each UCS server you’ve defined.

 

Tags: , , , , , , , ,

PowerShell – Get the percentage of physical and virtual servers from your VMware environment

With the current focus on Corporate Social Responsibility (CSR) including Green IT, it might be important to know what percentage of servers has been virtualized.

This script I made will use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. You can specify multiple Virtual Center servers if desired.

 

Tags: , , , , , , , , , , , , , , , , ,

PowerShell – Slipstream Office 2003 Updates

In yesterday’s post I described how you could extract Office 2003 updates. When they are extracted however, they still need to be slipstreamed into the package. I also created this script to automate the slipstreaming.

Basically for each extracted patch (.msp) file, it runs msiexec with the correct parameters. So if you have other msi packages that need multiple patch (.msp) files applied to it, you could use this script as a foundation as well.

 

Tags: , , , , , , , , , , ,

PowerShell – Extract Office 2003 Updates

Not so long ago I had to create a new Office 2003 Administrative Installation Point.

There were 2 choices:

  1. Use the default ISO and have WSUS handle patching after each install.
  2. Slipstream all available patches in the Office 2003 Administrative Installation Point.

Ofcourse option 2 is the best choice, because then the package will be the most secure from the moment the software is deployed. Also it saves bandwidth and time.

To slipstream updates into Office 2003, there are basically 4 steps:

  1. Extract the original Office 2003 files.
  2. Download the updates you want to slipstream.
  3. Extract the updates you want to slipstream.
  4. Slipstream the updates into the extracted Office 2003 files.

You can imagine that the older the source files are, the more updates there are to be slipstreamed. So it is best to use an ISO/CD of Office 2003 with the latest Service Pack.

Still if you have the latest Service Pack, you need to slipstream more than 20 updates. I personally don’t like these kind of manual tasks, so I created this script to do the extraction of the updates for me.

Ofcourse this script can be used to extract other kinds of updates as well..

 

Tags: , , , , , ,

 
Follow

Get every new post delivered to your Inbox.

Join 740 other followers

%d bloggers like this: