Remko Weijnen's Blog (Remko's Blog)

About Terminal Server, Citrix, Delphi and other stuff

Bit Shifting in PowerShell

I needed to dome some Bit Shifting in PowerShell but unfortunately PowerShell lacks operator for Bit Shifting. I searched the .NET Framework for anything that allows for bit shifting but was unable to find anything suitable.

I didn’t want to revert to C# so I implemented shift left and shift right functions in PowerShell.

The code isn’t really pretty and could probably be improved (comments/improvements are welcome!) but here goes (please note that I implemented for bit shifting a byte):

(more…)

  • 3 Comments
  • Filed under: PowerShell
  • Today I was troubleshooting a message that appeared when a user tries to edit a document from SharePoint on a Citrix XenApp server.

    The user browsed to a word document on Sharepoint and selected “Edit in Microsoft Office Word” from the Combobox:

    Edit in Microsoft Office Word

    This would present the following error message to the user:

    'Edit Document' requires a Windows SharePoint Services-compatible application and Microsoft Internet Explorer 6.0 or greater.

    (more…)

    From a script I needed to schedule a project in RES Automation Manager 2011 for a particular server.

    imageThis can be done with the WMC.exe commandline tool as documented in the Admin Guide. However we must specify the agent’s GUID instead of it’s name. We can of course use the AM console to get the agent’s GUID but it’s more flexible to script this.

    imageUnfortunately there’s no API we can call so I am directly quering the AM database using a PowerShell script.

    The script read the database server and database name from the registry so it assumes you have the AM console installed.

    (more…)

  • 0 Comments
  • Filed under: PowerShell, RES
  • 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…)

  • 0 Comments
  • Filed under: PowerShell
  • 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…)

  • 1 Comment
  • Filed under: Citrix, 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…)

  • 1 Comment
  • Filed under: PowerShell, script
  • 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…)

    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…)

  • 0 Comments
  • Filed under: 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…)

  • 0 Comments
  • Filed under: PowerShell
  • Profile

    Tags

    Recent Tweets

    Views

    Donate


    Blogroll


    Categories


    Archives