Category Archives: Tool

[Updated] Citrix PVS: Sync Local vDisk Store #PowerShell

I’ve reworked the Sync-PvsLocalStore.ps1 script. And from compatibility perspective it supports now vDisks in avhdx as well as avhd format.

Sync-PvsLocalStore.ps1 supports Citrix Provisioning Services Farms w/ local vDisk store. This kind of architecture is not best practice but in the field, especially among the mid-sized companies you’ll find such PVS farms.

The purpose of this script is to copy or rather sync changed and new versions of one or more given vDisks between the local Stores within a Farm of two or more PVS servers. Basically, you can think of the Sync-PvsLocalStore.ps1 as a wrapper for Robocopy.exe /MIR with some extra brains on top. That is because it is able to detect and exclude a Maintenance Version of a vDisk from the copy process, meaning that the script only spreads out the latest Production and Test versions of a vDisk while it doesn’t bloat the stores with Maintenance versions that is work in progress typically.

The usage is very simple. Look at this example:

You need to specify one ‘MasterServer’, one or more ‘MemberServer’, the path of the Store (needs to be the same on each server), one or more vDisk names, the name of the corresponding Site and Store. The two latter params help the script to identify any Maintenance Version.

Sync-PvsLocalStore.ps1 needs to be run on a system where the PVS Console or rather its command-line interface MCLI.EXE is installed. (Although there’s a PowerShell module for PVS, the script utilizes the old school MCLI.EXE in order to support a wider range of PVS versions.)

Please note: The script leverages robocopy’s MIR switch; meaning that it may delete so called EXTRA files on the given member PVS server(s) that are not present in the local vDisk store of the given master PVS server! Therefore, this script makes only sense when you consequently use only one PVS Server for vDisk maintenance. You need to keep that in mind when using this script.

Hope this helps

ISESteroids 2.0 Random Features

Tags :

Category : Tool , Windows PowerShell

A few months ago, I wrote only a short note about the (at that time) upcoming release of the PowerShell module ISESteroids. More precisely, ISESteroids is an Add-On for PowerShell ISE by PowerShell MVP Tobias Weltner. This time I’ll highlight some randomly chosen features.

First start

Ok, that is not really a feature. You can start ISESteroids by entering Start-Steroids. Owing to the Module Auto-Loading feature, this will load the ISESteroids module. But, mind the “sensitivity” of Module Auto-Loading! It already loads a module behind the scenes as soon as you “touch” it with Get-Command, Get-Help and Tab Expansion. So be prepared that ISESteroids loads when you invoke commands like Get-Command -Module ISESteroids, Get-Help Start-Steroids, and such…

Expert Level

In a nutshell, ISESteroids‘ objective is to assist you in writing better PowerShell code more quickly. As ISESteroids is so packed with features, however, it could twist that aim right around and tend to confuse especially beginners. If you start ISESteroids for the first time it will ask for the Expert Level. Whatever you’ll choose there, you can it later set to a more appropriate level by choosing the corresponding option the “Expert Level” menu.

Screenshot: Selecting the Expert Level


Yes, the concept of code snippets is already included in ISE. It’s a bit halfhearted, though. ISESteroids uses ISE’s snippet mechanism to the advantage it deserves. If you press the default snippet key sequence STRG-J ISESteroids opens the snippet selector. First surprise: The snippets are organized in folders. Selecting a folder leads to corresponding code snippets. (Btw, with the backspace key you move up in the folder structure.) Second suprise: The snippet selector allows for adding new folders and new snippets.

Screenshot: Selecting a code snippet

Screenshot: Snippet Manager


If you deal with the latest PowerShell version only, be happy in your bubble. My field experience differs regarding the PowerShell versions my scripts have to support. PowerShell 1.0 really faded away meanwhile, but I still stumble over version 2.0 for example. ISESteroids helps you to handle or rather to prevent compatibility issues by marking code that isn’t compatible to the targeted PowerShell version. So, be sure to check the appropriate option in the “Compatibility” menu. Apart from version-related compatibility ISESteroids can mark commands that are not shipping with PowerShell default, thus you have a sort of visual reminder of your script/code requirements.

Screenshot: Selecting compatibility

Risk Management

While you’re scripting, ISESteroids by default checks/analyzes your code against pre-defined risks. On potential risk detection you’ll be notified without attracting attention meaning that ISESteroids will change the risk status indicator from green to yellow or red. Keep an eye on that indicator. You’ll find it in ISE’s status bar and you can click it to enable/disalbe Autochecking, to approve the script, etc. Furthermore, there’s an option to manage black/white lists. (Note that the trail version doesn’t allow you to edit the pre-defined rules.)

Screenshot: Risk Management settings

Screenshot: Risk assessment result


Starting from say 100 lines of code you find yourself scrolling more and more. If you deal with rather huge scripts on a regular basis you’ll definitely like ISESteroids‘ ScriptMap feature. Turned on, it will show a preview of the entire script. If you move the mouse pointer over that ScriptMap area it will act as a reading-glass that helps you to identify the code region in question. A single click will navigate to the chosen code region.

Screenshot: Navigating with ScriptMap

Navigating to function definition/references back and forth

Apart from ScriptMap ISESteroids has more help to offer regarding navigation within (huge) script files. Above the definition of a function ISESteroids displays the number of references to this function (within the same file).

Clicking on this information will navigate to the references:

If you want to navigate (back) to the function definition, right-click on the reference to function in question on choose “Go To Definition”:

CloneView and split screen

Again, if you regularly deal with larger scripts ISESteroids helps you to minimize the ongoing efforts to navigate back and forth in the code. CloneView displays the current editor in a detached external window. Just right-click anywhere within the editor you want to clone and choose “Open CloneView”. The split screen feature divides the current editor in two sections, thus you’re able to simultaneously view/work on different sections of a single script.

Screenshot: Splitted editor window

Navigation Bar

OMG, yet another about navigating huge scripts? Yes and far more than that. If you turn on the Navigation Bar, at first sight you can both search text and instantly navigate to any function within the loaded script by selecting a function from the list.

Screenshot: Selecting a function to navigate to from the Navigator Bar

Beyond that, the Navigation Bar…

  • offers access to a couple of snippets and templates,
  • enables you to create a function from selected code,
  • and enables you to export a selected function to a new/existing PowerShell module

Screenshot: Selecting snipptes and templates from the Navigation Bar

Screenshot: Create a function from selected code from the Navigation Bar

Screenshot: Export a selected function to a new PowerShell module from the Navigation Bar

File Version History

To come to an end, ISESteroids has a rather casual file versioning feature. For those who care about version control but don’t want to get worked up over git, svn, csv, tfs, etc. ISESteroids can keep a file version history for a given file. (Behind the scenes it maintains a zip archive with all the past major and minor versions.)

Screenshot: File version history feature

Bottom line: Give it a try!

ISESteroids 2.0 is getting off the starting blocks…

Tags :

Category : Tool , Windows PowerShell

… and you should give it a try: ISESteroids 2.0

To tell you the truth, up to yesterday I had some kind of prejudice against Tobias Weltner’s ISESteroids meaning that I considered it a PowerShell ISE Add-On that rather addresses a beginner’s needs.

During the 3rd german ‘PowerShell Community Konferenz 2015’ I changed my opinion. While giving talks, Tobias showcased by the way several times features of the upcoming release. I changed opinions. ISESteroids not only help you to produce better PowerShell solutions, but also it brings you to speed – regardless if your level is beginner, advanced, expert, guru whatever.

For example, imagine you’re challenged to write an advanced function with different parameter sets, mandatory parameters, and some optional parameters. With ISESteroids loaded, you can do things back to front, in other words you start with writing the syntax as you want it to be, such as…

After that you just need to highlight the code, right-click, select the ISESteroids action to create a function, and – voilà – you get a neatly written skeleton for a function that exactly matches the syntax specifications you made.

Another great feature I saw in action was a WPF GUI builder that requires/interacts with Visual Studio.

I could continue listing my memory minutes. But, it still would be just the tip of the iceberg. ISESteroids is packed features you need to discover while working with it. So do I

Login VSI Benchmarking Suite Reaches New Maturity Level

Category : Tool

Login Virtual Session Indexer, the core product of my dutch friends at Login VSI B.V., goes Version 4.0. It will be available as from tomorrow, that is May 2, 2013.

How time flies! I clearly remember how sometime in 2008/2009 a small team of brainiacs in the lab of Login Consultants started to build the first version of Login VSI. Their intention was to finally address the increasing demand in VDI and SBC projects for a tool that helps to measure performance, impact, and scalability of different infrastructure options. The need for such a benchmarking tool was really urgent as other existing tools were (and are) too expensive, too complicated and not vendor-independent. After one, two years of development Login VSI made its breakthrough: shortly after an Express edition of the tool had been made available for free it was downloaded thousands and thousands of times and thus became a well-known benchmarking tool for VDI and SBC environments. Quite rightly Login VSI claims to be the “de facto industry standard”. As of this blog post Login VSI has been adopted by vendors, by system integrators, by service providers as well as eventually you? (See also the list of Whitepapers based on testing with Login VSI.)

Enough storytelling. What’s new in the new major release of Login VSI? In a nutshell: It is easier to setup and integrate; it is easier to create tests; it simulates real world users in a more realistic way. Login VSI is better than ever! A lot of effort has been put into the new release. It is improved in every respect, from A to Z.

Since a picture paints a thousand words, I’ve prepared a couple of screenshots below. Skimming over the gallery you may will notice that Login VSI v4 has a new, more intuitive GUI which includes a wizard that helps to create and configure tests, an integrated workload editor, and a new dashboard that displays real-time testing results/progress. So much for the outer appearances. But where do the inner values come in? Version 4 introduces a new meta language for easier workload customization. In order to improve the test realism, for one thing the duration of the standard workloads has been increased from 14 to 48 minutes loop and for another thing the datasets now offer 1000 different documents per type, more and larger websites, and a video library in every format. This ensures a far more realistic simulation of a real world variety in data usage.

Function to Bulk-Register PowerShell Snap-Ins

I wrote the PowerShell function below, Register-PSSnapin, to facilitate the usage of the InstallUtil.exe program in order to register a series of PowerShell snap-ins. Since this utility isn’t located in the “normal” command path, you have to find it in the .NET Framework’s directory. Or, with my function you just don’t care 😉

Side note: in PowerShell 2.0 the concept of snap-ins is substantially replaced by binary modules. Apart from the fact that the core of PowerShell 2.0 is delivered as snap-ins, many software vendors still provide a PowerShell snap-in to allow for command-line based administration and automation. (For example the latest release of Citrix Provisioning Services 6.0 ships a PowerShell Snap-in.)

How To Script Downloads With BITS? #Batch

Tags :

Category : Batch , Tool

When it comes to large file downloads one should use a download manager which at least is able to resume broken downloads. Windows has a built-in download manager service called Background Intelligent Transfer Service(BITS). Some of us at Login Consultants (including me) prefer to script large file downloads with the Microsoft’s BITS Admin Utility – Bitsadmin. This article explains how to use Bitsadmin to download a file.

The BITS service is built into Windows XP, Vista, Server 2003, and Server 2008. For example the Windows Automatic Update, WSUS 3.0, or Microsoft SCCM 2007 depend on BITS to transfer files like Windows Updates and software packages. For one thing BITS has been designed for robustness over slow or unstable network connections, and for another thing BITS is a background process that economizes on bandwidth usage. If a download does not complete due to a network problem or restart of your machine, BITS will automatically try to continue the download from where it left off, and repeat this until the whole file has been retrieved. BITS file transfers can be invoked and managed from the command line with the Bitsadmin utility which is part of the Windows Support Tools.

Please note that this article applies to Bitsadmin 3.0 and the version of BITS that is included in Windows Vista SP1.

In order to download a file with Bitsadmin, respectively BITS, you need to type a series of Bitsadmin commands to create a download job, to add the file the the job, eventually to set credentials and proxy settings, and finally to start the download job. Bitsadmin has many command line switches, for this see also Bitsadmin’s help by typing “bitsadmin” at the command prompt. For our purposes we need the switches CREATE, ADDFILE, SETNOTIFYCMDLINE, COMPLETE, SETCREDENTIALS (maybe), and RESUME.

Let’s say we want to download the english copy of the Automated Installation Kit (AIK) for Windows Vista SP1 and Windows Server 2008. This is a real large download, the ISO file is about 1350 MB. Since the URL string is very large the examples below don’t contain the complete download URL. If you want to reproduce the examples you must use this URL:

1. Create Job

First of all, we need to create a new download job with Bitsadmin /CREATE

Bitsadmin will confirm job creation by echoing the job GUID like “Created job {58C6770A-AB4E-477C-8944-33246EC8791E}”. For now, the job is created and its state is suspended. (Therefore, we will need to resume the job later in order to start the download process.)

2. Add File

Now we can add the file to the job with Bitsadmin /ADDFILE. We need to specify the job name, the download URL, and the file’s local name.

Again, Bitsadmin will confirm the action. (Hint: if you want to add multiple files to a job take a look at Bitsadmin’s switch /ADDFILESET which reads each file’s remote URL and local name from a text file.)

3. Optional Settings

The job is still in suspended state, and we are almost ready to start the download. But to start with we should pay attention to three important and useful Bitsadmin switches: COMPLETE, SETNOTIFYCMDLINE, and SETCREDENTIALS

By default, Bitsadmin doesn’t tell anything about a finished file transfer. Even worse, though BITS may have downloaded a file completely you won’t find it unless you have completed the job explicitly. To kill two birds with one stone we will use Bitsadmin /SETNOTIFYCMDLINE to launch Bitsadmin /COMPLETE as loon as the transfer is finished. (Virtually, SETNOTIFYCMDLINE enables you to set a command line to execute for notification when the file download is finished.)

Maybe the file is located on a password protected web server. In this case you can add credentials to a job using Bitsadmin /SETCREDENTIALS. This time you have to go without an example. Please refer to Bitsadmin’s syntax help by typing “bitsadmin” at the command line.

4. Start/Resume Download

Finally, we are ready to resume the download job with Bitsadmin /RESUME:

Now, BITS is downloading the file in the background. Since we have defined the launch of an according job completion command on transfer completion we can just wait and see… or check out some Bitsadmin command lines:

5. Monitor or Cancel Job

How to display information about the BITS job?

How to retrieve the size of the BITS job?

How to retrieve the number of bytes transferred?

How to monitor the BITS copy manager?

How to cancel the BITS job?

How to delete all BITS jobs?

6. Write a Shell Script

The batch file below, Bits-Download.cmd, simplifies the usage of Bitsadmin: