Remko Weijnen's Blog (Remko's Blog)

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

Archive for the ‘PowerShell’ Category

PowerShell RegEx Fun

I am writing a script that is going to automate a number of manual steps involved in creating a new image with Citrix PVS.

First step is to copy the most recent base image which is kept in a folder structure. The folder name is always YYYY-MM-DD (description):

image

I needed to determine the most recent folder and didn’t want to rely on creation date. Instead I walk the directory tree and filter the date out of the filename with a regular expression:

(more…)

Convert MCli output into PowerShell Objects

imageI was experimenting today with the PowerShell cmdlets for Citrix Provisioning Server. I was surprised to learn that the output of these cmdlets are not PowerShell types such as collections and objects with methods and properties but just plain text output.

A google search for a method to quickly convert the garbage output to objects led me to this blog post by Frank Peter. He describes a clever use of the switch statement with regular expressions with the Get-DiskInfo cmdlet.

Using Frank’s code as a basis I wrote a generic function that converts Mcli output to an array of objects.

(more…)

Script to Get Computer OU

Just some quick code to get the OU Name of the computer we run the script on.

VBS:

PowerShell:

Scripting Citrix Online Plugin Settings

The Citrix Online Plugin has a number of settings that can be changed. This includes things as Window Size and Color Depth:

Session Options | Window size | Default | Full Screen | Requested Color Quality

In my case I wanted to preset the Window size to Full Screen so using Process Monitor I checked where the Online Plugin writes this setting. I Used a Filter that includes only the Online Plugin (PNAMain.exe) and the RegSetValue Operation:

Filter on Process Name is PNAMain.exe | Operation is RegSetValue

(more…)

imageAfter reading Andy Morgan’s (excellent) blog post about Removing Screen Resolution and Personalize shell extensions from a users desktop session I couldn’t help it.

imageI had to write a PowerShell script to take ownership of the mentioned registry keys. So here goes:

(more…)

Read Maximum Password Age with PowerShell

imageI needed to read out the Maximum Password age with a PowerShell script in a Windows 2003 domain.

Reading out the maxPwdAge attribute is a trivial task  in PowerShell (I am re-using the function AdsLargeIntegerToInt64):

In my case this returns the value -78624000000000 but how do we interpret this?

(more…)

Embedding images in HTML

I was creating a small dialog in an .hta file and to make a little prettier for the user I included a company logo:

SNAGHTMLdfa805

But I wanted to deploy the .hta as a single file.

(more…)

Some Active Directory attributes return an 8 byte integer in the form of an IADsLargeInteger interface. An example is the pwdLastSet attribute from a user object.

Because the IADsLargeInteger object doesn’t provide type information PowerShell cannot read the HighPart and LowPart properties.

So I wrote the function below to get the Int64 value of an IADsLargeInteger:

(more…)

Set homefolder permissions with PowerShell

imageToday one of my collegues asked me to write a script that performs two actions for all users of a certain Organizational Unit:

  1. Ensure that each user has modify permissions on their homefolder
  2. Make each user visible in the Exchange Address List.

Sounds like a PowerShell job right?

I reused my function to set NTFS Permissions by SID:

(more…)

Construct AQS date range with PowerShell

imageFor a script I needed to create an AQS (Advanced Query Syntax) Query that contained a date range.

An example of such is a range is: date:11/05/04..11/10/04

However we need to account for regional settings where for example the data seperator and the order of day and month may be different.

In my example I wanted to match any data that is 30 days or older so let’s do this in PowerShell:

(more…)

Donate


Blogroll


Categories


Archives