home lab, software development, and other stuff i find interesting

Category Archives: Development

Introduction

Version 4 of my scripts have been released today, and with it a whole host of changes have been made. Version 3 of the scripts are still available if you can’t move to v4 yet.

A recap

The QA checks came about as a need to verify the build of new servers for various customers and their different environments. All new server builds are usually done with a custom gold image template; however this image still lacks many of the additional tools and configuration settings needed before it can be accepted into support.

Most of this extra tooling and configuration should be automated, however checks are still needed to make sure each customer or environment has their specific settings in place.

Version 4

With version 4 came an almost total rewrite of the checks. Every check script was looked at and changed to make sure it was using up-to-date code and more modern cmdlets. The checks were also rewritten to remove the need to specify a specific server name in them, as they now run within a remote WinRM session.

Change Log

A change log of major updates is listed here. Of note the two major updates is that PowerShell v4 is now a requirement and that the entire package is now multilingual. If people are willing to help me translate, the Checks, QA Engine and Settings Configuration Tool can now be shown in almost any language (Right-To-Left languages probably won’t work – I’ll be looking into this if there is a requirement).

Documentation

The GitHub Wiki for this project has been updated with lots of documentation that should help you get up and running quickly in your environment. The first guide you should look at is the Quick Start Guide.

There is also an in-depth guide to the Settings Configuration Tool. This tool helps you to configure the scripts for your specific environments and is invaluable in the amount of time it saves.

Introduction

Drop down lists are great for selecting from a list of items. However, a plain text list can be difficult to read if there are a lot of items. Icons help to make a list easier to read, however the standard ComboBox control does not support images.

OwnerDraw

As with the ListView control that I customised here, the ComboBox can also be modified.

My new control supports not only adding icons, but also indenting and disabling specific items.

The first image shows multicoloured icons with randomly applied indenting. Indents can be any value you require. Only 0 and 1 are shown here. The second image shows all green icons, however items 3 and 4 are “disabled”. Notice that the icons and text appear greyed out.

ComboxBox List Items

There is a little more to adding items to the ComboBox list however. You need to create a new object, populate it your required values, then add that to the $IconComboItems array. Once you have created all your items, add them to the ComboBox control

Conclusion

Obviously there is a lot of code missing that is used in the screen shots, but the important part is there in order to get you up and running. Have a play, and let me know what you think in the comments below.

Introduction

I am writing a small PowerShell tool that will perform a few checks against several virtual machines in vCenter. I wanted to show the results in a nice grid view. The ListView control is the easy choice for this.

Basic Grid

This picture below shows the basic layout that I started with (with random dummy data), and as you can see it’s not great.

The ‘P’ass and ‘F’ail display could be better, icons would be great. The problem is that the basic ListView does not support more than one icon in the grid – usually the first one next to the name.

There are some tweaks you can do to move the single icon about by changing columns, but it’s still just one icon.

OwnerDraw

With a lot of the Windows forms controls they support an OwnerDraw method. This allows developers to hack around with controls and make them do things that they can’t normally do – like having more that one icon in a ListView, including its subitems. 🙂

Looks great doesn’t it.!

It works by replacing “P” or “F” in the top screenshot with “ICON|x” where “x” is the index number of the image you want to use. For example, my ticks are in position 1, and the crosses are position 2. Therefore “ICON|1” or “ICON|2” would be used. My code has an additional option of displaying an icon and text in the same box. To show this use “BOTH|x|text”

The Code

In order to change a standard ListView into an awsome ListView does not require a lot of code.

about 50 lines of additional code for the OwnerDraw part, and 3x lines in the middle of the ListView definition.

The first SubIcons_DrawColumnHeader can largely be ignored. It’s needed to draw the default column headers.

The second is the main worker. It turns the text “ICON|x” into the image to be used, and displays it centred in the subitem window. It also displays “BOTH|x|text” with the icon on the left with the text left-aligned next to it.

Conclusion

Obviously there is a lot of code missing that is used in the screen shots, but the important part is there in order to get you up and running. Have a play, and let me know what you think in the comments below.

Introduction

Following on from my Server QA Scripts post, I have since created a GUI form to make the configuration a lot easier to do. The tool is fully written in PowerShell and is uploaded to my GitHub page.

To Use

Introduction

To use, just open a PowerShell windows and start the `QA-Settings-Configurator.ps1` script.

You’ll be presented with the following window.

QA GUI Page 1

Click the Set Check Location button and location the folder where your scripts are located. Once done, you will be able to change the language (if any) and a base settings file (if any others exist). Click Import Settings when done.

The script will then scan the scripts folder and load the selected settings file.

Select Required Checks

The next page lists all the checks available and automatically selects all the checks enabled in the settings file.

QA GUI Page 2

You can select or deselect any check that you feel best suits your environment. For example, if you don’t use McAfee Antivirus in your environment, you wouldn’t want to check for the McAfee Antivirus agent, therefore, you would deselect the COM01 check.

Once you have finished your selections, click the Next > button.

QA Check Values

The third page has several tabs, one tab for each of the check sections. Within each of the these tabs is a list of the checks you selected, as well as the required settings for each check.

QA GUI Page 3

Double-click each of the settings and change the values that you require for your environment, remembering to check the settings in each of the tabs.

When you are happy with your settings, select the final page.

Generate QA

QA GUI Page 4

Now that you have completed your changes, enter a short code for your QA script file. This will be the unique code that the QA compiler will use to name your QA script file. For example, a short code of “ACME” will generate a QA script called “QA_ACME_v3.xx.xxxx.ps1“. Also enter a company name for the HTML reports that are generated.

Click Save Settings when you are ready, and enter a filename to save your settings as. Generate a compiled QA script from this page too by clicking the Generate QA Script button.

Other functions

If you happen to loose your settings file, you can restore them by clicking the Restore Settings File button. Select the location of a compiled QA script and the function will recreate the settings INI file for you.

Introduction

At the start of 2015 my company was still building a lot of new Windows servers manually (physical and virtual). Each of these servers had a check sheet of what was completed and what wasn’t. Sometimes stuff would be missed for one reason or another, which is why the servers typically went through a process of QA (Quality Assurance).

This QA check was a time consuming manual process that involved someone logging into each server and checking that everything was built and configured as it should be, as well as making sure all the correct tooling was installed (AV, SCOM and SCCM agents, etc). This typically took a good 2 hours per server. Results were filled in to an Excel spreadsheet and filed away somewhere as an audit trail.

My Solution

Fast forward to today, and those servers are now mostly built via our in-house automation process, however there is still some manual configuration that is required. The QA process has also improved. I have taken the manual spreadsheet and converted it into separate PowerShell scripts that are ‘compiled’ into one large script, that is just shy of 8000 lines.!

This script takes less than a minute to complete over 70 checks and write a HTML report for each viewing

My scripts are currently at version 3 and have been released into the wild so that other people can take advantage of the hard work I put in to create them.

The Scripts

I have spent the best part of 18 months creating and tweaking these scripts. I started with a broken system of about 40 QA checks and got them working. I then expanded and enhanced the number and quality of the scripts as well as the underlying engine.

As of today (2016-09-06) there are 75 checks. Hopefully with some community input and help we can increase that.

Download

Introduction

The ‘New >‘ item on the right-click menu is quite handy. It can list a huge amount of document types for you to create new documents. Most of the time these work, other times they don’t.

Problem

As this list grows when new applications are installed, it rarely shrinks when an application is removed. This can lead to dead links.

Another issue with this list is custom desktops for Citrix XenApp users, or other users on locked down, permissions based terminal servers. There may be links in the list that a particular user doesn’t have access to.

Solution

One solution is to just ignore it. Users may log tickets sayinIg they can’t access an application they are not allowed to have, causing you to waste time and effort on chasing your tails.

While I was working with a particular Citrix XenApp install quite a few years ago, I created a script in KIX that would remove the entire list of applications, except for “Text Document” I have recently updated this script for PowerShell and thought that I would share it with you.

As you can see from the screen shots, all the new document links have gone except for the only one we want.

Download

Introduction

As a follow on to the shut down home-lab script, I have also written a power up script for when power is restored to your home-lab and you want to get it up and running again quickly. This script will assume your hosts are powered on and waiting, but nothing else has happened yet.

The Script

The script can be downloaded below, make sure you read though it fully and understand how it works. I am not responsible for anything going wrong.!

At the top of the script, you will need to change the settings to match your own home-lab.

The servers in your critical folder, in the order they should be powered up

Starting from the known host (the same as in the shut down script), it will power up your critical servers in the order specified on line 9. Once they are fully powered on (it checks that the VMware tools are available) it will check and wait for the VMware VirtualCenter Server service to be up and running. Once running, the script will then start all the remaining virtual machines.

Download

Download the script from the link below, and again, make sure you test it before putting it live.!

Introduction

If you run a large home-lab like I do, shutting it down in an emergency can be a slow process, especially if you are panicking about your UPS staying up long enough. You DO have a UPS don’t you.!?

I had written a PowerCLI script for myself that was custom to my specific lab. I have since made it more generic so that everyone can use it if they wanted to. The script does rely on one specific criteria for your home-lab though.

Home-Lab Layout

Within the vCenter VMs and Templates view, you can organise your VMs into folders to help separate them into logical groups. This has no bearing on the VMs themselves, its purely for your information.

As you can see by this image, I have a folder called Critical that I use to hold my important VMs. These are…

live-dc : The DHCP and DNS server for my home network,

svr-dc : The domain controller, as well as DHCP and DNS for my private lab network,

svr-sql : The Microsoft SQL server for my private network. This holds all the databases for my lab,

svr-vc : The VMware virtual centre server for my home-lab.

This Critical folder is important in my script, as it controls which VMs are not shut down immediately, but must wait until the end and be shut down in a specific order.

The Script

The script can be downloaded below, make sure you read though it fully and understand how it works. I am not responsible for anything going wrong.!

At the top of the script, you will need to change the settings to match your own home-lab.

The servers in your critical folder, in the order they should be shut down in

.

How long to wait for a clean shut down before killing power to a virtual machine

Specific ESXi Host Name

The reason for a specific host name in the script, is so that when you come to power on your home-lab, you will know exactly which host will hold your critical VMs. The script will migrate all powered off VMs as well as your critical ones to this host before powering everything down. If you have a number of hosts it’s helpful if you don’t need to check each one for your domain controller is virtual centre server.

Download

Download the script from the link below, and again, make sure you test it before putting it live.!

Introduction

Please Note: This is an old application I wrote in 2011. It is no longer updated or supported.

This tool allows you to view exactly which applications are published on which servers within your Citrix Metaframe/Presentation Server/XenApp farm. Applications are shown in tree format as shown in the management console, and servers can be shown either alphabetically or grouped in their zones

Applications can also be published or unpublished from the farm with a simple click of the mouse – as long as editing is enabled first.
It should work with all versions of Citrix Presentation Server and XenApp prior to XenApp 6.

Please note, this will only shown what’s published, not installed.

Prerequisites

Most Microsoft Windows 2003 Servers should already have the required files installed by default. However, if this is not the case, the following links will help you download and install the pre-requisites…

Installation

Download the ZIP file below and extract the file onto one of your Citrix farm servers or a network share,

From one of your Presentation/XenApp servers, execute the extracted file,

The following window will appear, with the current server name already filled in…

Click the Build Matrix button and wait.
Depending on the size of your farm, this could take a while. A progress counter will inform you of its status.
Once complete, the window will change, and once resized it should show you something that looks like this…

Filtering

You can also filter the list or applications and servers that are shown…

Options

There are also a couple of options too…

Download

If you are interested in this tool, please download it from the link below…