RSS

Tag Archives: Script

PowerShell – Using PowerShell 5 to automate the installation of your favorite Windows applications

In this blog post I will explain why to automate installations of Windows applications and how you can do this.

Why automate the installation of applications?

But first, why is this useful? Well this depends on your situation and there are probably many good reasons. For me though, it basically boils down to this:

  1. I often reinstall my computers with new (preview) versions of Windows operating systems and having to install applications each time is a waste of time. Also sometimes you forget to install some things.
  2. On a regular basis, friends and family either want me to install or upgrade their PC and I want to provide them with a standard set of programs that most people need/want without having to spend a lot of time on it. By example virus scanner, burning program, media player, codecs, etc.
  3. I want to update existing installed applications to the latest (and hopefully more secure and feature packed) versions.
  4. When installing applications, there are often checkboxes enabled to install other applications (you generally don’t want to install). Automated solutions using packages generally prevent these additional unwanted applications from installing.

Which tools to use to automate the installation of applications?

Before PowerShell 5 preview was released, I used both Ninite and Chocolatey to perform to automate installations. They both have their advantages as described on this wiki page.

The PowerShell 5 preview version of OneGet installs and searches software from Chocolatey repositories, but support of additional repositories will come in subsequent versions.

How to automate the installation of applications using PowerShell 5 preview?

To automate the installation of applications a couple of things are required:

  1. You need to determine which applications you want to install automatically.
  2. You need to determine the package name that Chocolatey uses for this application. Options include:
    -Using a browser to browse the Chocolatey packages
    -Using PowerShell and a part of the name of the application you’re looking for. By example if you’re looking for Irfanview, use:
    Find-Package -Name “fan”
  3. Store the package names to install somewhere (e.g. in a .txt file on OneDrive for easy access). My .txt file by example includes:
    AdobeReader
    Directx
    ffdshow
    Flashplayerplugin
    GoogleChrome
    Imgburn
    IrfanView
    Javaruntime
    Keepassx
    Mp3tag
    mpc-hc
    PDFCreator
    Silverlight
    TeamViewer
    Totalcommander
    Winrar
    greenshot
  4. Use the Install-Package cmdlet to install all the packages whose name is in the file from step 3.
    Install-Package -Name (Get-Content C:\OneDrive\AppsToInstall.txt) -Confirm:$False
  5. Wait for the programs to install

My opinion

It’s great to be able to use PowerShell to install my list of favorite applications similar to like I did with Chocolatey and I’m also looking forward to see what benefits the additional repositories will bring in the future.

I did encounter some errors however while trying to install some applications like Firefox and dotnet3.5. But since it’s still a preview, this will probably be fixed.

For regular users, I think they are better off sticking to by example Ninite because they’re often afraid of anything that involves a CLI.

Blog posts by other people about OneGet

Some other people have also blogged about the OneGet module and have gone in more technical detail, so be sure to take a look at their posts as well:

More information about PowerShell 5 Preview including a download link

Windows Management Framework v5 preview, includes also Desired State Configuration (DSC) improvements and NetworkSwitch commandlets to manage network switches that pass the Certified for Windows Program. For more information including a download link, you can read the initial blog post. : Windows Management Framework V5 Preview

 

 

 

Tags: , , , , , , , ,

LazyWinAdmin – a great powershell script for more efficient Windows management

The last couple of months I’ve been playing around a lot with PowerShell and I’ve also been trying to make some nice GUI versions for my script using PowerShell Studio 2012 from Sapien Technologies Inc. While looking for more information how to best use PowerShell Studio 2012 I came across LazyWinAdmin.

LazyWinAdmin is a great tool created by Francois-Xavier C that will save you a lot of time. It provides you with most of the commonly used tools and commands in a very structured and easy to access way. In the picture below you can see what I mean.

For more info on the tool, take a look at the website and be sure to download and test it yourself.

If you want to take a look at other useful tools I’ve found in the past, take a look at my applications list.

 
 

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: , , , , , , , , ,

Microsoft – Run programs and scripts under the local system user context

In the past I’ve had numerous occasions where I wanted to run a program or system to run under the local system user context. Most of them involved customers and application administrators that wanted to have a service or scheduled task configured. They often weren’t able to tell me if it was sufficient to run the service or scheduled task as local system or that a special service account would have to be created.

The issue I always ran into when I wanted to test this, is that you had to provide a password that you didn’t know if you wanted to use “Run As” with the local system account.

Recently I ran into the “Run As System” application. It enables you to start a program or run command and script under a local system account. It is UAC compatible, but it requires administrative privileges.

Another use of the “Run As System” application is if you want to access files or folders that are normally not accessible for users. This can come in handy when troubleshooting Offline Files. The tool might not work correctly with Windows Explorer though, so you should consider using other tools like Total Commander.

Other methods to run something as system can be found here.

For more tools and applications, take a look at my website: http://bjornhouben-web.sharepoint.com/Lists/Applications/Summary.aspx

 

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

PowerShell – Advanced Function Template

I’m currently reading the great book “Learn PowerShell In A Month Of Lunches“.As it turns out there is a lot I can still improve on (which I already knew ofcourse).

Part of the book covers properly creating an advanced function. I’ve taken these sample scripts and added additional comments so I can more easily use it for future functions. You can find it here.

 
Leave a comment

Posted by on March 4, 2013 in Uncategorized

 

Tags: , , , , , ,

PowerShell – Extract specific info from multiple source winaudit files

I run Winaudit on each server/system and save it to a central location named <computername>.csv                 This way I have access to a lot of information about each system. If you need a specific subset of information for each system however, you don’t want to have to open each file manually to get this information.

This script will parse each <computername>.csv to extract specifc information and save it to one new file containing this info for all parsed separate files.

 
Leave a comment

Posted by on February 25, 2013 in Automation, ICT, Microsoft, Powershell

 

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

PowerShell – Get-GroupMemberships

This script determines the group membership of Active Directory users.

In this case, some users are member of multiple functional groups (groupname “*-core”), while the design assumes a user can only be a member a single functional group. This script helps determine the functional groups they are a member of.

Especially with a large number of users, scripting will save you a lot of time.

 

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

 
Follow

Get every new post delivered to your Inbox.

Join 853 other followers

%d bloggers like this: