Remko Weijnen's Blog (Remko's Blog)

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

Archive for the ‘PowerShell’ Category

RC4 Encryption in PowerShell

For an upcoming blog post I needed to decrypt some data using the rc4 algorithm. I wanted to do this with PowerShell but sadly PowerShell and the .NET framework have no functions for it.


So I needed to implement it (download at the bottom of the post):


  • 1 Comment
  • Filed under: PowerShell
  • For an upcoming Blog post I needed to convert a Byte Array to a Hex string in PowerShell and vice versa.

    PowerShell doesn’t come with HexToBin or BinToHex functions so here’s my attempt at it:


  • 1 Comment
  • Filed under: PowerShell
  • Parse RES Building Blocks with PowerShell

    Customer uses Citrix XenApp 5 with ThinApp, RES Workspace Manager and RES Workspace Extender.

    An application integration strategy is defined, the picture below displays the strategy and preferred order:


    Customer wanted to know the type (1..7) for all applications currently defined in RES Workspace Manager.

    I decided to export all the Applications from RES WM as Building Blocks. This results in a folder with XML files. I decided to parse the XML files with a PowerShell script.


  • Filed under: PowerShell, RES
  • A customer had partially implemented a (written) policy in the past where the the Local Administrator account was renamed according to a special convention.

    This policy stated that the Administrator account needed to be renamed to admin with the computername as a prefix.

    However they didn’t know exactly on which machines this policy had been applied to in the past. I was asked to write a script that would check a list of machine names, query the Administrator account name and write this in a new list.

    The Administrator account has a Well Known SID of S-1-5-21-xxxxxxx-500 where xxxxxxx is the SID of the computer.


  • Filed under: PowerShell
  • After joining a new Windows 2008 R2 Server to the domain I could not login to the domain.

    I would get the following error message:

    The security database on the server does not have a computer acocunt for this workstation trust relationship.

    Additionally the following error was logged in the Eventlog:

    Event ID 3 | Error 1787 | Error Code 0x7 | KDC_ERR_S_PRINCIPAL_UNKNOWN | A Kerberos Message was received



    My Network Places Internals

    Nethood IconI am using a PowerShell script to copy some elements of from the users old profile location to a new location. This includes the Nethood ("My Network Places") folder which contains the Network Places shortcuts.

    A user reported that she could not save documents to Network Places anymore and after inspection the Network Places shortcuts were broken.

    I started comparing the old Nethood folder to the new and observed the following difference in Explorer:


    When copying entries from the Nethood folder with Explorer manually they worked fine, so somehow Explorer gives the Nethood folder special treatment.


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


  • Filed under: PowerShell
  • Create Active Directory Group with PowerShell

    If you want to Create an Active Directory group with PowerShell there are a few things you need to be aware of:

    First of all there is no direct way to create new objects in Active Directory. You always need to bind to the Domain or an Organizational Unit and call the Create method.


    However the group is not yet complete:

    Group name (pre-Windows 2000)


    When Launching a PowerShell script I noticed the following error: “AuthorizationManager check failed.

    AuthorizationManager check failed.| At line:1 char:2 | Microsoft.PowerShell_profile.ps1'

    This happens because either the Current User or the All Users PowerShell profile is empty.


  • 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.