Remko Weijnen's Blog (Remko's Blog)

About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like

Archive for the ‘PowerShell’ Category

After changing AWS accounts I resetup my API key so I could use the AWS PowerShell CmdLets.

However even though I was sure I configured everything correctly I couldn’t call any EC2 cmdlet. More about that further below but let’s refresh how to setup an API key for PowerShell:

The procedure to do this is quite simple:

First you create an IAM user (go to Services | IAM) then in the left treeview select Users or use this direct link.

Identity and Access Management (IAM) Treeview

Click Add users or use this direct link, give the user a name and select “Access key – Programmatic access”

In the next screen select the appropriate permissions, in this screenshot I’m using AdministratorAccess but this of course means you’re giving this user the permissions to do absolutely anything.

So have a good look at the minimum permissions that you actually require.

Click Next on the Add tags screen and the Review screen should look something like this:

On the next screen you will get the Access key ID and the Secret access key. Note that this is the only time you will get to see the Secret access key so use the copy button or Download the .csv file (but delete it from disk when you’re done of course).


  • Filed under: AWS, PowerShell
  • Sign APPX packages with PowerShell

    I have been working with Microsoft’s Desktop App Converter a lot recently. Even though there’s an option to autosign the resulting package with the -Sign switch I prefer to sign APPX packages myself using signtool.

    The reason is that I can send UWP packages to testers for sideloading without requiring them to import the auto generated certificate (which is different on each (re)build).

    However I always forget the exact path to signtool.exe (this comes with the Windows SDK).

    The Windows 10 SDK is installed by default in C:\Program Files (x86)\Windows Kits\10.

    Signtool.exe will be in the folder<sdkpath>\bin\<version>\<platform>\signtool.exe.

    As there are multiple version of Windows 10 there are multiple version of the SDK and you can install those concurrently.

    But then I found the PowerShell cmdlet Resolve-Path which “Resolves the wildcard characters in a path, and displays the path contents”.

    This does exactly what I need:


    Wow, Resolve-Path is a perfect example of the many hidden gems in PowerShell!

    So I decided to wrap signtool.exe in a PowerShell cmdlet as PowerShell also makes it easy to locate the correct code signing certificate from the certificate store. (more…)

  • Filed under: PowerShell
  • imageAs you may heard, the API’s returning the Operating System version have changed, started with Windows 8.1 and Server 2012 R2.

    The reason for this change is Application Compatibility but let’s take a little closer look into this why.

    As an application developer there may be a need to check the version of the OS you’re running on. A typical example is when you are using an API that only works on a specific Windows version (and up). Or the other round, you’re not supporting an older version of Windows (say Windows XP as an example).

    A common error in such version checks is to check for a specific Windows version but forget to take new (not yet released) versions into account.


  • 1 Comment
  • Filed under: PowerShell
  • Just a very quick post (more like a note to self) but I wanted to split a string with the $ sign in PowerShell:

    Took me a little while to realize that this doesn’t work as the split operator in Windows PowerShell uses a regular expression in the delimiter, rather than a simple character.

    The easy fix is to Escape the $ sign with a backslash:

    Or alternatively use the SimpleMatch option:

    The 0 represents the “return all” value of the Max-substrings parameter. You can use options, such as SimpleMatch, only when the Max-substrings value is specified.

  • Filed under: PowerShell
  • Recently support for NPAPI has been removed from Google Chrome. While understandable from a security point of view it does mean that some plugins no longer work.

    A good example is VMware’s Client Integration Plugin where we’ve lost the ability to upload an ovf template. While VMware has published a fix for vCenter (see this kb), it has not been fixed for vCloud Director:

    The attempted operation cannot be performed using this browser. Re-try using an alternative method:

- Use the VMware OVF Tool to perform the operation. You can download the OVF Tool and its User Guide from the OVF Tool product page at
- Use a browser and platform combination that is supported by vCloud Director for this operation. For the supported browser and platform combinations, see the Release Notes for this version of vCloud Director.


    In versions prior to 6.0 VMware supplied the VCSA (vCenter Server Appliance) as an OVF template that could be imported directly.

    Starting with version 6.0 the installation process has changed and now consist of an .iso file containing a custom, HTML based, installer. Vladan Seget has a nice blog post where he describes the installation.

    This installation process is annoying, it needs a separate client (Windows) machine to run the installer on, requires the Client Integration Plugin (which doesn’t appear to run well on chrome now that support for npapi/dpapi has been removed):
    Please install the Client Integration Plugin 6.0 provided in the vCenter Server Appliance ISO image (requires quitting the browser)

    But even worse is that we cannot import VCSA 6.0 in vCloud Director. Even converting the OVF inside the iso file doesn’t help because vCloud directory lacks support for Deployment Options.


    ShareFileLogoThe Citrix ShareFile Sync application is quite limited in functionality, one of those limitations is that you can only synchronize to a single (one) local folder.

    As Helge Klein wrote in his excellent article "Configuring Citrix ShareFile Sync from PowerShell" this is simply a GUI restriction and not a restriction in the actual ShareFile sync engine.

    Helge describes that you can easily do this in PowerShell with the following example:

    While the command was accepted, nothing was synchronized.


    Handling ini files in PowerShell

    Ini File IconThis morning Aaron Parker was wondering if Hash Tables could be used to work with ini files:

    Aaron Parker | @stealthpuppy | @remkoweijnen @msh_dave need to see if this approach works for editing INI files

    I thought it was a great idea because in Hash Tables you can use the . operator to get or set a Hash Table entry. But I wondered what to do with sections in ini files. Then I got the idea to use nested Hash Tables for that.

    The result is two functions, one to read an ini file into a nested Hash Table and one function to write it back to an ini file.


  • Filed under: PowerShell
  • In a PowerShell script I needed to sort a hash table by byte value (not alphabetically, lowercase parameters will be listed after uppercase ones). An example for this requirement is the Amazon Product Advertising API.

    Consider the following hashtable as an example:

    If we use the Sort-Object to order the list (note that we need to use the GetEnumerator method):

    We will get the following result:

    If you use the -CaseSensitive switch the resulting order will remain the same.


  • Filed under: PowerShell
  • Get Actual CPU Clock Speed with PowerShell

    To get the best performance out of Virtual Desktops it is essential that the power configuration in the system BIOS and the HyperVisor are configured for maximum performance.

    Many people have blogged about the importance of these settings like, Andrew Wood, Helge Klein and Didier Van Hoye. So I will not go into details again.

    But how do you check from a Virtual Machine if you are actually running at full clock speed or not?

    I have written a PowerShell script to do just that (requires at least PowerShell v3).

    Here are some screenshots:

    Running with "High Performance profile":

    CPU Clock Speed with d"High Performanced" Power Profile

    Running with "Balanced" power profile:

    CPU Clock Speed with High Performance Balanced Profile


  • Filed under: PowerShell
  • Blogroll