<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PowerShell on Remko's Blog</title><link>https://remkoweijnen.nl/blog/categories/powershell/</link><description>Recent content in PowerShell on Remko's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 20 Dec 2017 15:00:33 +0000</lastBuildDate><atom:link href="https://remkoweijnen.nl/blog/categories/powershell/index.xml" rel="self" type="application/rss+xml"/><item><title>Sign APPX packages with PowerShell</title><link>https://remkoweijnen.nl/blog/2017/12/20/sign-appx-packages-powershell/</link><pubDate>Wed, 20 Dec 2017 15:00:33 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2017/12/20/sign-appx-packages-powershell/</guid><description>&lt;p&gt;I have been working with Microsoft&amp;rsquo;s Desktop App Converter a lot recently. Even though there&amp;rsquo;s an option to autosign the resulting package with the &lt;code&gt;-Sign&lt;/code&gt; switch I prefer to sign APPX packages myself using signtool.&lt;/p&gt;
&lt;p&gt;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).&lt;/p&gt;
&lt;p&gt;However I always forget the exact path to signtool.exe (this comes with the &lt;a href="https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk" target="_blank" rel="noopener"&gt;Windows SDK&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The Windows 10 SDK is installed by default in &lt;code&gt;C:\Program Files (x86)\Windows Kits\10&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Signtool.exe will be in the folder &lt;code&gt;&amp;lt;sdkpath&amp;gt;\bin\&amp;lt;version&amp;gt;\&amp;lt;platform&amp;gt;\signtool.exe&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As there are multiple version of Windows 10 there are multiple version of the SDK and you can install those concurrently.&lt;/p&gt;
&lt;p&gt;But then I found the PowerShell cmdlet &lt;a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/resolve-path?view=powershell-3.0" target="_blank" rel="noopener"&gt;Resolve-Path&lt;/a&gt; which &amp;ldquo;Resolves the wildcard characters in a path, and displays the path contents&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;This does exactly what I need:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2017/12/image-5.webp" class="glightbox" data-type="image" data-gallery="post-4204"&gt;&lt;img loading="lazy" decoding="async" style="display: inline;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2017/12/image_thumb-5.webp" alt="image" width="433" height="83" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Wow, Resolve-Path is a perfect example of the many hidden gems in PowerShell!&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Get Windows 10 Version Number with PowerShell</title><link>https://remkoweijnen.nl/blog/2017/04/04/get-windows-10-version-number-powershell/</link><pubDate>Tue, 04 Apr 2017 16:54:02 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2017/04/04/get-windows-10-version-number-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2017/04/image.webp" class="glightbox" data-type="image" data-gallery="post-4133"&gt;&lt;img loading="lazy" decoding="async" style="float: right; margin: 0px 0px 0px 3px; display: inline;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2017/04/image_thumb.webp" alt="image" width="119" height="103" align="right" /&gt;&lt;/a&gt;As you may heard, the API&amp;rsquo;s returning the Operating System version have &lt;a href="https://msdn.microsoft.com/windows/compatibility/operating-system-version-changes-in-windows-8-1"&gt;changed&lt;/a&gt;, started with Windows 8.1 and Server 2012 R2.&lt;/p&gt;
&lt;p&gt;The reason for this change is Application Compatibility but let&amp;rsquo;s take a little closer look into this why.&lt;/p&gt;
&lt;p&gt;As an application developer there may be a need to check the version of the OS you&amp;rsquo;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&amp;rsquo;re not supporting an older version of Windows (say Windows XP as an example).&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Split a string by dollar sign ($) in PowerShell</title><link>https://remkoweijnen.nl/blog/2017/03/13/split-string-dollar-sign-powershell/</link><pubDate>Mon, 13 Mar 2017 15:28:13 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2017/03/13/split-string-dollar-sign-powershell/</guid><description>&lt;p&gt;Just a very quick post (more like a note to self) but I wanted to split a string with the $ sign in PowerShell:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,J29uZSR0d28kdGhyZWUkZm91ciRmaXZlJyAtc3BsaXQgJyQn"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s1"&gt;&amp;#39;one$two$three$four$five&amp;#39;&lt;/span&gt; &lt;span class="n"&gt;-split&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;$&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Took me a little while to realize that this doesn&amp;rsquo;t work as the &lt;a href="https://msdn.microsoft.com/en-us/powershell/reference/3.0/microsoft.powershell.core/about/about_split"&gt;split&lt;/a&gt; operator in Windows PowerShell uses a regular expression in the delimiter, rather than a simple character.&lt;/p&gt;</description></item><item><title>Upload ovf/ova to vCloud Director with PowerShell</title><link>https://remkoweijnen.nl/blog/2015/10/14/upload-ovfova-to-vcloud-director-with-powershell/</link><pubDate>Wed, 14 Oct 2015 10:08:49 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2015/10/14/upload-ovfova-to-vcloud-director-with-powershell/</guid><description>&lt;p&gt;Recently support for NPAPI has been &lt;a href="https://support.google.com/chrome/answer/6213033?hl=en"&gt;removed&lt;/a&gt; from Google Chrome. While understandable from a security point of view it does mean that some plugins no longer work.&lt;/p&gt; &lt;p&gt;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 &lt;a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;amp;cmd=displayKC&amp;amp;externalId=2130672"&gt;this kb&lt;/a&gt;), it has not been fixed for vCloud Director:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2015/10/image7.webp" class="glightbox" data-type="image" data-gallery="post-3620"&gt;&lt;img loading="lazy" decoding="async" title="Browser Compatiblity Warning" style="display: inline" alt="The attempted operation cannot be performed using this browser. Re-try using an alternative method:&amp;#10;&amp;#10;- 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 https://www.vmware.com/support/developer/ovf/.&amp;#10;- 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." src="https://remkoweijnen.nl/blog/wp-content/uploads/2015/10/image_thumb7.webp" width="326" height="204" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Deploy VCSA 6 to vCloud Director or vCloud Air</title><link>https://remkoweijnen.nl/blog/2015/10/05/deploy-vcsa-6-to-vcloud-director-or-vcloud-air/</link><pubDate>Mon, 05 Oct 2015 20:11:47 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2015/10/05/deploy-vcsa-6-to-vcloud-director-or-vcloud-air/</guid><description>&lt;p&gt;In versions prior to 6.0 VMware supplied the VCSA (vCenter Server Appliance) as an OVF template that could be imported directly.&lt;/p&gt; &lt;p&gt;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 &lt;a href="http://www.vladan.fr/install-vmware-vcsa-6-0/"&gt;blog post&lt;/a&gt; where he describes the installation.&lt;/p&gt; &lt;p&gt;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):&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2015/10/image.webp"&gt; &lt;br /&gt;&lt;img loading="lazy" decoding="async" title="Wheb prompted, allow access to the Client Integration Plugin" style="margin: 4px 0px; display: inline" alt="Please install the Client Integration Plugin 6.0 provided in the vCenter Server Appliance ISO image (requires quitting the browser)" src="https://remkoweijnen.nl/blog/wp-content/uploads/2015/10/image_thumb.webp" width="417" height="37" /&gt;&lt;/a&gt; &lt;br /&gt;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. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Synchronizing Citrix ShareFile with PowerShell</title><link>https://remkoweijnen.nl/blog/2015/01/28/synchronizing-citrix-sharefile-with-powershell/</link><pubDate>Wed, 28 Jan 2015 11:39:17 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2015/01/28/synchronizing-citrix-sharefile-with-powershell/</guid><description>&lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2015/01/ShareFileLogo.gif" data-type="image" data-gallery="post-3555"&gt;&lt;img loading="lazy" decoding="async" title="ShareFileLogo" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: right; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="ShareFileLogo" src="https://remkoweijnen.nl/blog/wp-content/uploads/2015/01/ShareFileLogo_thumb.gif" width="64" align="right" height="64" /&gt;&lt;/a&gt;The 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.&lt;/p&gt; &lt;p&gt;As Helge Klein wrote in his excellent article &amp;quot;&lt;a href="https://helgeklein.com/blog/2014/01/configuring-citrix-sharefile-sync-powershell/"&gt;Configuring Citrix ShareFile Sync from PowerShell&lt;/a&gt;&amp;quot; this is simply a GUI restriction and not a restriction in the actual ShareFile sync engine.&lt;/p&gt; &lt;p&gt;Helge describes that you can easily do this in PowerShell with the following example:&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;Add-SyncJob example&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download="add-syncjob-example.ps1" href="data:text/plain;charset=utf-8;base64,QWRkLVN5bmNKb2IgLUFwcGxpY2F0aW9uSWQgMSAtQXBwbGljYXRpb25OYW1lICJQb3dlclNoZWxsIiAtQWNjb3VudCBoZWxnZWtsZWluLnNoYXJlZmlsZS5jb20KLVJlbW90ZUZvbGRlck5hbWUgImZvYzg2YzE5LWQ5MDQtNDM0YS05ZDY3LXh4eHh4eHh4eHh4eCIgLUxvY2FsRm9sZGVyUGF0aCAiRDpcRGF0ZW5cU3luYyB0byBTaGFyZUZpbGUiCi1BdXRoVHlwZSA0IC1Vc2VyTmFtZSB4eHh4eHhAaGVsZ2VrbGVpbi5jb20gLVN5bmNEaXJlY3Rpb24gMiAtUGFzc3dvcmQgIk1ZIFNIQVJFRklMRSBQQVNTV09SRCI="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Add-SyncJob&lt;/span&gt; &lt;span class="n"&gt;-ApplicationId&lt;/span&gt; &lt;span class="mf"&gt;1&lt;/span&gt; &lt;span class="n"&gt;-ApplicationName&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;PowerShell&amp;#34;&lt;/span&gt; &lt;span class="n"&gt;-Account&lt;/span&gt; &lt;span class="n"&gt;helgeklein&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;sharefile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;com&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;-RemoteFolderName&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;foc86c19-d904-434a-9d67-xxxxxxxxxxxx&amp;#34;&lt;/span&gt; &lt;span class="n"&gt;-LocalFolderPath&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;D:\Daten\Sync to ShareFile&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;-AuthType&lt;/span&gt; &lt;span class="mf"&gt;4&lt;/span&gt; &lt;span class="n"&gt;-UserName&lt;/span&gt; &lt;span class="n"&gt;xxxxxx&lt;/span&gt;&lt;span class="nv"&gt;@helgeklein&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;com&lt;/span&gt; &lt;span class="n"&gt;-SyncDirection&lt;/span&gt; &lt;span class="mf"&gt;2&lt;/span&gt; &lt;span class="n"&gt;-Password&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;MY SHAREFILE PASSWORD&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;While the command was accepted, nothing was synchronized.&lt;/p&gt;</description></item><item><title>Handling ini files in PowerShell</title><link>https://remkoweijnen.nl/blog/2014/07/29/handling-ini-files-powershell/</link><pubDate>Tue, 29 Jul 2014 15:03:08 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2014/07/29/handling-ini-files-powershell/</guid><description>&lt;p&gt;&lt;img title="Ini File" style="float: right; margin: 0px 0px 20px; display: inline" alt="Ini File Icon" src="http://www.fileinfo.com/images/icons/files/128/ini-41.png" width="60" align="right" height="60" /&gt;This morning Aaron Parker was wondering if Hash Tables could be used to work with ini files:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/image8.webp" class="glightbox thickbox" data-type="image" data-gallery="post-3527"&gt;&lt;img loading="lazy" decoding="async" title="Aaron Parker | Twitter | @stealthpuppy" style="display: inline" alt="Aaron Parker | @stealthpuppy | @remkoweijnen @msh_dave need to see if this approach works for editing INI files" src="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/image_thumb8.webp" width="320" height="132" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Sorting a hashtable by byte value in PowerShell</title><link>https://remkoweijnen.nl/blog/2014/07/22/sorting-hashtable-byte-value-powershell/</link><pubDate>Tue, 22 Jul 2014 12:03:28 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2014/07/22/sorting-hashtable-byte-value-powershell/</guid><description>&lt;p&gt;&lt;img style="float: right; display: inline" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTEtkV3oLDtyNhyD55yu4uoWbX_oIrnDuJDl4NK6zC59MPNHCnynsqZ9yae" width="96" align="right" height="96" /&gt;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 &lt;a href="http://docs.aws.amazon.com/AWSECommerceService/latest/DG/rest-signature.html" target="_blank"&gt;Amazon Product Advertising API&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Consider the following hashtable as an example:&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;Example Hash Table&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download="example-hash-table.ps1" href="data:text/plain;charset=utf-8;base64,JHBhcmFtcyA9IEB7fQokcGFyYW1zLkFkZCgiQXNzb2NpYXRlVGFnIiwgImR1bW15IikKJHBhcmFtcy5BZGQoIkFXU0FjY2Vzc0tleUlkIiwgIkFLSUFJT1NGT0ROTjdFWEFNUExFIikKJHBhcmFtcy5BZGQoIklkVHlwZSIsICIwNjc5NzIyNzY5IikKJHBhcmFtcy5BZGQoIk9wZXJhdGlvbiIsICJJdGVtTG9va3VwIik="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="vm"&gt;@&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;AssociateTag&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;dummy&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;AWSAccessKeyId&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;AKIAIOSFODNN7EXAMPLE&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;IdType&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;0679722769&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Operation&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ItemLookup&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If we use the Sort-Object to order the list (note that we need to use the &lt;a href="http://technet.microsoft.com/en-us/library/ee692803.aspx" target="_blank"&gt;GetEnumerator&lt;/a&gt; method):&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;Sort Hash Table&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download="sort-hash-table.ps1" href="data:text/plain;charset=utf-8;base64,JHBhcmFtcy5HZXRFbnVtZXJhdG9yKCkgfCBTb3J0LU9iamVjdCBOYW1l"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;GetEnumerator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Sort-Object&lt;/span&gt; &lt;span class="n"&gt;Name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We will get the following result:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;Sort Results&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download="sort-results.ps1" href="data:text/plain;charset=utf-8;base64,TmFtZSAgICAgICAgICAgICAgICAgICAgICAgICAgIFZhbHVlCi0tLS0gICAgICAgICAgICAgICAgICAgICAgICAgICAtLS0tLQpBc3NvY2lhdGVUYWcgICAgICAgICAgICAgICAgICAgZHVtbXkKQVdTQWNjZXNzS2V5SWQgICAgICAgICAgICAgICAgIEFLSUFJT1NGT0ROTjdFWEFNUExFCklkVHlwZSAgICAgICAgICAgICAgICAgICAgICAgICAwNjc5NzIyNzY5Ck9wZXJhdGlvbiAgICAgICAgICAgICAgICAgICAgICBJdGVtTG9va3Vw"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="n"&gt;Value&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;----&lt;/span&gt; &lt;span class="p"&gt;-----&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;AssociateTag&lt;/span&gt; &lt;span class="n"&gt;dummy&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;AWSAccessKeyId&lt;/span&gt; &lt;span class="n"&gt;AKIAIOSFODNN7EXAMPLE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;IdType&lt;/span&gt; &lt;span class="mf"&gt;0679722769&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Operation&lt;/span&gt; &lt;span class="n"&gt;ItemLookup&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you use the &lt;code&gt;-CaseSensitive&lt;/code&gt; switch the resulting order will remain the same.&lt;/p&gt;</description></item><item><title>Get Actual CPU Clock Speed with PowerShell</title><link>https://remkoweijnen.nl/blog/2014/07/18/get-actual-cpu-clock-speed-powershell/</link><pubDate>Fri, 18 Jul 2014 16:29:24 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2014/07/18/get-actual-cpu-clock-speed-powershell/</guid><description>&lt;p&gt;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.&lt;/p&gt; &lt;p&gt;Many people have blogged about the importance of these settings like, &lt;a href="http://blog.atlantiscomputing.com/2013/08/powering-vdi-performance-best-practices-for-optimal-virtual-desktop-performance/" target="_blank"&gt;Andrew Wood&lt;/a&gt;, &lt;a href="http://helgeklein.com/blog/2013/05/the-effects-of-power-savings-mode-on-vcpu-performance/" target="_blank"&gt;Helge Klein&lt;/a&gt; and &lt;a href="http://workinghardinit.wordpress.com/2011/06/20/consider-cpu-power-optimization-versus-performance-when-virtualizing/" target="_blank"&gt;Didier Van Hoye&lt;/a&gt;. So I will not go into details again.&lt;/p&gt; &lt;p&gt;But how do you check from a Virtual Machine if you are actually running at full clock speed or not?&lt;/p&gt; &lt;p&gt;I have written a PowerShell script to do just that (requires at least PowerShell v3).&lt;/p&gt; &lt;p&gt;Here are some screenshots:&lt;/p&gt; &lt;p&gt;Running with &amp;quot;High Performance profile&amp;quot;:&lt;/p&gt; &lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/clip_image002.jpg" data-type="image" data-gallery="post-3516"&gt;&lt;img loading="lazy" decoding="async" title="Windows PowerShell" style="display: inline" alt="CPU Clock Speed with d&amp;quot;High Performanced&amp;quot; Power Profile" src="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/clip_image002_thumb.jpg" width="240" height="74" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Running with &amp;quot;Balanced&amp;quot; power profile:&lt;/p&gt; &lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/clip_image0025.jpg" data-type="image" data-gallery="post-3516"&gt;&lt;img loading="lazy" decoding="async" title="Windows PowerShell" style="display: inline" alt="CPU Clock Speed with High Performance Balanced Profile" src="https://remkoweijnen.nl/blog/wp-content/uploads/2014/07/clip_image0025_thumb.jpg" width="240" height="74" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>RC4 Encryption in PowerShell</title><link>https://remkoweijnen.nl/blog/2013/04/05/rc4-encryption-in-powershell/</link><pubDate>Fri, 05 Apr 2013 16:27:32 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2013/04/05/rc4-encryption-in-powershell/</guid><description>&lt;p&gt;For an upcoming blog post I needed to decrypt some data using the &lt;a href="http://en.wikipedia.org/wiki/RC4" target="_blank"&gt;rc4 algorithm&lt;/a&gt;. I wanted to do this with PowerShell but sadly PowerShell and the .NET framework have no functions for it.&lt;/p&gt; &lt;p&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" border="0" alt="File:RC4.svg" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/RC4.svg/800px-RC4.svg.png" width="299" height="134" /&gt;&lt;/p&gt; &lt;p&gt;So I needed to implement it (download at the bottom of the post):&lt;/p&gt;</description></item><item><title>Convert Bin to Hex and Hex to Bin in PowerShell</title><link>https://remkoweijnen.nl/blog/2013/04/05/convert-bin-to-hex-and-hex-to-bin-in-powershell/</link><pubDate>Fri, 05 Apr 2013 11:17:24 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2013/04/05/convert-bin-to-hex-and-hex-to-bin-in-powershell/</guid><description>&lt;p&gt;For an upcoming Blog post I needed to convert a Byte Array to a Hex string in PowerShell and vice versa.&lt;/p&gt; &lt;p&gt;PowerShell doesn't come with HexToBin or BinToHex functions so here's my attempt at it:&lt;/p&gt;</description></item><item><title>Parse RES Building Blocks with PowerShell</title><link>https://remkoweijnen.nl/blog/2012/12/07/parse-res-building-blocks-with-powershell/</link><pubDate>Fri, 07 Dec 2012 13:29:20 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/12/07/parse-res-building-blocks-with-powershell/</guid><description>&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Background&lt;br&gt;
&lt;/span&gt;&lt;/strong&gt;Customer uses Citrix XenApp 5 with ThinApp, RES Workspace Manager and RES Workspace Extender.&lt;/p&gt;
&lt;p&gt;An application integration strategy is defined, the picture below displays the strategy and preferred order:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/12/image12.webp" data-type="image" data-gallery="post-2850"&gt;&lt;img loading="lazy" decoding="async" style="display: inline;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/12/image_thumb12.webp" alt="image" width="399" height="136" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration: underline;"&gt;Question&lt;/span&gt;&lt;/strong&gt;&lt;br&gt;
Customer wanted to know the type (1..7) for all applications currently defined in RES Workspace Manager.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;</description></item><item><title>Query Administrator Account Name with PowerShell</title><link>https://remkoweijnen.nl/blog/2012/10/25/query-administrator-account-name-with-powershell/</link><pubDate>Thu, 25 Oct 2012 15:22:47 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/10/25/query-administrator-account-name-with-powershell/</guid><description>&lt;p&gt;A customer had partially implemented a (written) policy in the past where the the Local Administrator account was renamed according to a special convention.&lt;/p&gt;
&lt;p&gt;This policy stated that the Administrator account needed to be renamed to admin with the computername as a prefix.&lt;/p&gt;
&lt;p&gt;However they didn&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;The Administrator account has a &lt;a href="http://support.microsoft.com/kb/243330"&gt;Well Known SID&lt;/a&gt; of S-1-5-21-xxxxxxx-500 where xxxxxxx is the SID of the computer.&lt;/p&gt;</description></item><item><title>Error 1787 when logging in with domain account</title><link>https://remkoweijnen.nl/blog/2012/08/21/error-1787-when-logging-in-with-domain-account/</link><pubDate>Tue, 21 Aug 2012 11:43:35 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/08/21/error-1787-when-logging-in-with-domain-account/</guid><description>&lt;p&gt;After joining a new Windows 2008 R2 Server to the domain I could not login to the domain.&lt;/p&gt; &lt;p&gt;I would get the following error message:&lt;/p&gt; &lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/08/clip_image001.webp" data-type="image" data-gallery="post-2717"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="Error 1787" alt="The security database on the server does not have a computer acocunt for this workstation trust relationship." src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/08/clip_image001_thumb.webp" width="422" height="116" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Additionally the following error was logged in the Eventlog:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/08/image5.webp" class="glightbox thickbox" data-type="image" data-gallery="post-2717"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="Event Properties" alt="Event ID 3 | Error 1787 | Error Code 0x7 | KDC_ERR_S_PRINCIPAL_UNKNOWN | A Kerberos Message was received" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/08/image_thumb5.webp" width="216" height="240" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;#160;&lt;/p&gt;</description></item><item><title>My Network Places Internals</title><link>https://remkoweijnen.nl/blog/2012/07/19/my-network-places-internals/</link><pubDate>Thu, 19 Jul 2012 11:26:12 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/07/19/my-network-places-internals/</guid><description>&lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/07/image2.webp" data-type="image" data-gallery="post-2673"&gt;&lt;img loading="lazy" decoding="async" style="display: inline; float: right" title="Nethood" alt="Nethood Icon" align="right" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/07/image_thumb2.webp" width="56" height="52" /&gt;&lt;/a&gt;I am using a PowerShell script to copy some elements of from the users old profile location to a new location. This includes the Nethood (&amp;quot;My Network Places&amp;quot;) folder which contains the Network Places shortcuts.&lt;/p&gt; &lt;p&gt;A user reported that she could not save documents to Network Places anymore and after inspection the Network Places shortcuts were broken.&lt;/p&gt; &lt;p&gt;I started comparing the old Nethood folder to the new and observed the following difference in Explorer:&lt;/p&gt; &lt;p&gt;&lt;a class="glightbox thickbox" href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/07/image3.webp" data-type="image" data-gallery="post-2673"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="image" alt="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/07/image_thumb3.webp" width="409" height="80" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;When copying entries from the Nethood folder with Explorer manually they worked fine, so somehow Explorer gives the Nethood folder special treatment.&lt;/p&gt;</description></item><item><title>Bit Shifting in PowerShell</title><link>https://remkoweijnen.nl/blog/2012/05/10/bit-shifting-in-powershell/</link><pubDate>Thu, 10 May 2012 12:14:36 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/05/10/bit-shifting-in-powershell/</guid><description>&lt;p&gt;&lt;img style="display: inline; float: right" align="right" src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Rotate_left_logically.svg/210px-Rotate_left_logically.svg.png" width="129" height="86" /&gt;I needed to dome some &lt;a href="http://en.wikipedia.org/wiki/Bitwise_operation#Logical_shift"&gt;Bit Shifting&lt;/a&gt; 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.&lt;/p&gt; &lt;p&gt;I didn't want to revert to C# so I implemented shift left and shift right functions in PowerShell.&lt;/p&gt; &lt;p&gt;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):&lt;/p&gt;</description></item><item><title>Create Active Directory Group with PowerShell</title><link>https://remkoweijnen.nl/blog/2012/03/15/create-active-directory-group-with-powershell/</link><pubDate>Thu, 15 Mar 2012 15:51:23 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/03/15/create-active-directory-group-with-powershell/</guid><description>&lt;p&gt;If you want to Create an Active Directory group with PowerShell there are a few things you need to be aware of:&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt; &lt;p&gt;Example:&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,IyBCaW5kIHRvIE9VCiRvdSA9IFtBRFNJXSJMREFQOi8vT1U9T1U9R3JvdXBzLERDPUNvbnRvc28sREM9Q09NIgoKIyBDcmVhdGUgdGhlIEdyb3VwCiRncm91cCA9ICRvdS5DaGlsZHJlbi5BZGQoIkNOPVRlc3RHcm91cCIsICJHcm91cCIpCiRncm91cC5Db21taXRDaGFuZ2VzKCk="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Bind to OU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$ou&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;ADSI&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;LDAP://OU=OU=Groups,DC=Contoso,DC=COM&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Create the Group&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$group&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$ou&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Children&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;CN=TestGroup&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Group&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;CommitChanges&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;However the group is not yet complete:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image22.webp" class="glightbox" data-type="image" data-gallery="post-2554"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="TestGroup Properties" alt="Group name (pre-Windows 2000)" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb22.webp" width="404" height="184" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>AuthorizationManager check failed when starting PowerShell</title><link>https://remkoweijnen.nl/blog/2012/03/15/authorizationmanager-check-failed-when-starting-powershell/</link><pubDate>Thu, 15 Mar 2012 14:03:18 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/03/15/authorizationmanager-check-failed-when-starting-powershell/</guid><description>&lt;p&gt;When Launching a PowerShell script I noticed the following error: "&lt;em&gt;AuthorizationManager check failed.&lt;/em&gt;"&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image21.webp" class="glightbox" data-type="image" data-gallery="post-2551"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="PowerShell" alt="AuthorizationManager check failed.| At line:1 char:2 | Microsoft.PowerShell_profile.ps1&amp;#39;" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb21.webp" width="415" height="117" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This happens because either the Current User or the All Users PowerShell profile is empty.&lt;/p&gt;</description></item><item><title>Edit Document requires a Windows SharePoint Services-compatible application</title><link>https://remkoweijnen.nl/blog/2012/03/09/edit-document-requires-a-windows-sharepoint-services-compatible-application/</link><pubDate>Fri, 09 Mar 2012 14:23:11 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/03/09/edit-document-requires-a-windows-sharepoint-services-compatible-application/</guid><description>&lt;p&gt;Today I was troubleshooting a message that appeared when a user tries to edit a document from SharePoint on a Citrix XenApp server. &lt;p&gt;The user browsed to a word document on Sharepoint and selected &amp;ldquo;Edit in Microsoft Office Word&amp;rdquo; from the Combobox:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image8.webp" class="glightbox" data-type="image" data-gallery="post-2526"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="Sharepoint Document Context Menu" alt="Edit in Microsoft Office Word" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb8.webp" width="156" height="124" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;This would present the following error message to the user:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image9.webp" class="glightbox" data-type="image" data-gallery="post-2526"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="Windows Internet Explorer" alt="&amp;#39;Edit Document&amp;#39; requires a Windows SharePoint Services-compatible application and Microsoft Internet Explorer 6.0 or greater." src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb9.webp" width="415" height="73" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;</description></item><item><title>PowerShell script to read Agent Guid from Automation Manager</title><link>https://remkoweijnen.nl/blog/2012/03/06/powershell-script-to-read-agent-guid-from-automation-manager/</link><pubDate>Tue, 06 Mar 2012 16:00:06 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/03/06/powershell-script-to-read-agent-guid-from-automation-manager/</guid><description>&lt;p&gt;From a script I needed to schedule a project in RES Automation Manager 2011 for a particular server.&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image2.webp" class="glightbox" data-type="image" data-gallery="post-2500"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 3px 6px 0px; display: inline; float: left" title="image" alt="image" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb2.webp" width="65" height="65" /&gt;&lt;/a&gt;This can be done with the WMC.exe commandline tool as documented in the &lt;a href="http://support.ressoftware.com/automationmanageradminguide/15833.htm" target="_blank"&gt;Admin Guide&lt;/a&gt;. 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.&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image3.webp" class="glightbox" data-type="image" data-gallery="post-2500"&gt;&lt;img loading="lazy" decoding="async" style="display: inline; float: right" title="image" alt="image" align="right" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb3.webp" width="78" height="121" /&gt;&lt;/a&gt;Unfortunately there's no API we can call so I am directly quering the AM database using a PowerShell script.&lt;/p&gt; &lt;p&gt;The script read the database server and database name from the registry so it assumes you have the AM console installed.&lt;/p&gt;</description></item><item><title>PowerShell RegEx Fun</title><link>https://remkoweijnen.nl/blog/2012/03/06/powershell-regex-fun/</link><pubDate>Tue, 06 Mar 2012 11:19:53 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/03/06/powershell-regex-fun/</guid><description>&lt;p&gt;I am writing a script that is going to automate a number of manual steps involved in creating a new image with Citrix PVS.&lt;/p&gt; &lt;p&gt;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): &lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image1.webp" class="glightbox" data-type="image" data-gallery="post-2493"&gt;&lt;img loading="lazy" decoding="async" style="display: inline" title="image" alt="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/03/image_thumb1.webp" width="252" height="71" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;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:&lt;/p&gt;</description></item><item><title>Convert MCli output into PowerShell Objects</title><link>https://remkoweijnen.nl/blog/2012/02/29/convert-mcli-output-into-powershell-objects/</link><pubDate>Wed, 29 Feb 2012 21:35:49 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/02/29/convert-mcli-output-into-powershell-objects/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/image21.webp" class="glightbox" data-type="image" data-gallery="post-2468"&gt;&lt;img loading="lazy" decoding="async" style="display: inline; float: right" title="image" alt="image" align="right" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/image_thumb21.webp" width="83" height="83" /&gt;&lt;/a&gt;I 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.&lt;/p&gt; &lt;p&gt;A google search for a method to quickly convert the garbage output to objects led me to &lt;a href="http://www.out-web.net/?p=599" target="_blank"&gt;this blog post&lt;/a&gt; by Frank Peter. He describes a clever use of the switch statement with regular expressions with the Get-DiskInfo cmdlet.&lt;/p&gt; &lt;p&gt;Using Frank's code as a basis I wrote a generic function that converts Mcli output to an array of objects.&lt;/p&gt;</description></item><item><title>Script to Get Computer OU</title><link>https://remkoweijnen.nl/blog/2012/02/14/script-to-get-computer-ou/</link><pubDate>Tue, 14 Feb 2012 11:12:30 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/02/14/script-to-get-computer-ou/</guid><description>&lt;p&gt;Just some quick code to get the OU Name of the computer we run the script on.&lt;/p&gt;
&lt;p&gt;VBS:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;vbnet&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".vb" href="data:text/plain;charset=utf-8;base64,RnVuY3Rpb24gR2V0Q29tcHV0ZXJPVQoJRGltIG9ialN5c0luZm86IFNldCBvYmpTeXNJbmZvID0gQ3JlYXRlT2JqZWN0KCJBRFN5c3RlbUluZm8iKQoJRGltIG9iakNvbXB1dGVyOiBTZXQgb2JqQ29tcHV0ZXIgPSBHZXRPYmplY3QoIkxEQVA6Ly8iICYgb2JqU3lzSW5mby5Db21wdXRlck5hbWUpCglEaW0gb2JqT1UgOiBTZXQgb2JqT1UgPSBHZXRPYmplY3Qob2JqQ29tcHV0ZXIuUGFyZW50KQoJR2V0Q29tcHV0ZXJPVSA9IG9iak9VLk9VCkVuZCBGdW5jdGlvbgoKV3NjcmlwdC5FY2hvIEdldENvbXB1dGVyT1U="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-vbnet" data-lang="vbnet"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;Function&lt;/span&gt; &lt;span class="nf"&gt;GetComputerOU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="k"&gt;Dim&lt;/span&gt; &lt;span class="n"&gt;objSysInfo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;Set&lt;/span&gt; &lt;span class="n"&gt;objSysInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CreateObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;ADSystemInfo&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="k"&gt;Dim&lt;/span&gt; &lt;span class="n"&gt;objComputer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;Set&lt;/span&gt; &lt;span class="n"&gt;objComputer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GetObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;LDAP://&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;objSysInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ComputerName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="k"&gt;Dim&lt;/span&gt; &lt;span class="n"&gt;objOU&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;Set&lt;/span&gt; &lt;span class="n"&gt;objOU&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GetObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;objComputer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="n"&gt;GetComputerOU&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;objOU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;End&lt;/span&gt; &lt;span class="k"&gt;Function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;Wscript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Echo&lt;/span&gt; &lt;span class="n"&gt;GetComputerOU&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;PowerShell:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,ZnVuY3Rpb24gR2V0Q29tcHV0ZXJPVQp7CgkkU3lzSW5mbyA9IE5ldy1PYmplY3QgLUNvbU9iamVjdCAiQURTeXN0ZW1JbmZvIgoJJENvbXB1dGVyID0gW0FEU0ldKCJMREFQOi8vezB9IiAtZiAkU3lzSW5mby5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJDb21wdXRlck5hbWUiLCBbU3lzdGVtLlJlZmxlY3Rpb24uQmluZGluZ0ZsYWdzXTo6R2V0UHJvcGVydHksICRudWxsLCAkU3lzSW5mbywgJG51bGwpKQoJcmV0dXJuIChbQURTSV0kQ29tcHV0ZXIuUGFyZW50KS5PVQp9CgpHZXRDb21wdXRlck9V"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;GetComputerOU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$SysInfo&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;New-Object&lt;/span&gt; &lt;span class="n"&gt;-ComObject&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;ADSystemInfo&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$Computer&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;ADSI&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;LDAP://{0}&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;-f&lt;/span&gt; &lt;span class="nv"&gt;$SysInfo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;GetType&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="py"&gt;InvokeMember&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;ComputerName&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;System.Reflection.BindingFlags&lt;/span&gt;&lt;span class="p"&gt;]::&lt;/span&gt;&lt;span class="n"&gt;GetProperty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="vm"&gt;$null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$SysInfo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="vm"&gt;$null&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="no"&gt;ADSI&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="nv"&gt;$Computer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parent&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="py"&gt;OU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;GetComputerOU&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;</description></item><item><title>Scripting Citrix Online Plugin Settings</title><link>https://remkoweijnen.nl/blog/2012/02/13/scripting-citrix-online-plugin-settings/</link><pubDate>Mon, 13 Feb 2012 13:55:45 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/02/13/scripting-citrix-online-plugin-settings/</guid><description>&lt;p&gt;The Citrix Online Plugin has a number of settings that can be changed. This includes things as Window Size and Color Depth:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/SNAGHTML84f9096.webp" class="glightbox" data-type="image" data-gallery="post-2404"&gt;&lt;img loading="lazy" decoding="async" style="display: inline;" title="Options - Citrix online plug-in" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/SNAGHTML84f9096_thumb.webp" alt="Session Options | Window size | Default | Full Screen | Requested Color Quality" width="415" height="280" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/SNAGHTML8593f5c.webp" class="glightbox" data-type="image" data-gallery="post-2404"&gt;&lt;img loading="lazy" decoding="async" style="display: inline;" title="Process Monitor Filter" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/02/SNAGHTML8593f5c_thumb.webp" alt="Filter on Process Name is PNAMain.exe | Operation is RegSetValue" width="415" height="259" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Take ownership of a registry key in PowerShell</title><link>https://remkoweijnen.nl/blog/2012/01/16/take-ownership-of-a-registry-key-in-powershell/</link><pubDate>Mon, 16 Jan 2012 16:39:36 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2012/01/16/take-ownership-of-a-registry-key-in-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/01/image11.webp" class="glightbox" data-type="image" data-gallery="post-2327"&gt;&lt;img loading="lazy" decoding="async" style="display: inline; float: left;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/01/image_thumb11.webp" alt="image" width="101" height="70" align="left" /&gt;&lt;/a&gt;After reading Andy Morgan&amp;rsquo;s (excellent) blog post about&lt;a href="http://andrewmorgan.ie/2012/01/16/removing-screen-resolution-and-personalize-shell-extensions-from-a-users-desktop-session/" target="_blank"&gt; Removing Screen Resolution and Personalize shell extensions from a users desktop session&lt;/a&gt; I couldn&amp;rsquo;t help it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2012/01/image12.webp" class="glightbox" data-type="image" data-gallery="post-2327"&gt;&lt;img loading="lazy" decoding="async" style="display: inline; float: right;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2012/01/image_thumb12.webp" alt="image" width="38" height="37" align="right" /&gt;&lt;/a&gt;I had to write a PowerShell script to take ownership of the mentioned registry keys. So here goes:&lt;/p&gt;</description></item><item><title>Read Maximum Password Age with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/12/02/read-maximum-password-age-with-powershell/</link><pubDate>Fri, 02 Dec 2011 13:47:44 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/12/02/read-maximum-password-age-with-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/12/image1.webp" class="glightbox" data-type="image" data-gallery="post-2212"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 5px 0px 0px; display: inline; float: left" title="image" alt="image" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb1.webp" width="33" height="39" /&gt;&lt;/a&gt;I needed to read out the Maximum Password age with a PowerShell script in a Windows 2003 domain.&lt;/p&gt; &lt;p&gt;Reading out the &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms676863(v=vs.85).aspx" target="_blank"&gt;maxPwdAge&lt;/a&gt; attribute is a trivial task&amp;#160; in PowerShell (I am re-using the function &lt;a href="https://remkoweijnen.nl/blog/2011/12/01/convert-iadslargeinteger-to-int64-in-powershell/" target="_blank"&gt;AdsLargeIntegerToInt64&lt;/a&gt;):&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;text&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".txt" href="data:text/plain;charset=utf-8;base64,JGRvbWFpbiA9ICBOZXctT2JqZWN0IFN5c3RlbS5EaXJlY3RvcnlTZXJ2aWNlcy5EaXJlY3RvcnlFbnRyeQoKIyBSZWFkIG1heFB3ZEFnZSBhdHRyaWJ1dGUgYW5kIGNvbnZlcnQgdG8gSW50NjQKJG1heFB3ZEFnZSA9IEFkc0xhcmdlSW50ZWdlclRvSW42NCAkRG9tYWluLm1heFB3ZEFnZS5WYWx1ZQ=="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$domain = New-Object System.DirectoryServices.DirectoryEntry
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Read maxPwdAge attribute and convert to Int64
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$maxPwdAge = AdsLargeIntegerToIn64 $Domain.maxPwdAge.Value&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In my case this returns the value -78624000000000 but how do we interpret this? 
 &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Embedding images in HTML</title><link>https://remkoweijnen.nl/blog/2011/12/02/embedding-images-in-html/</link><pubDate>Fri, 02 Dec 2011 13:09:43 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/12/02/embedding-images-in-html/</guid><description>&lt;p&gt;I was creating a small dialog in an &lt;a href="http://en.wikipedia.org/wiki/HTML_Application" target="_blank"&gt;.hta file&lt;/a&gt; and to make a little prettier for the user I included a company logo:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTMLdfa805.webp" class="glightbox" data-type="image" data-gallery="post-2209"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTMLdfa805" border="0" alt="SNAGHTMLdfa805" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTMLdfa805_thumb.webp" width="270" height="206" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;But I wanted to deploy the .hta as a single file.&lt;/p&gt;</description></item><item><title>Convert IADsLargeInteger to Int64 in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/12/01/convert-iadslargeinteger-to-int64-in-powershell/</link><pubDate>Thu, 01 Dec 2011 16:03:46 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/12/01/convert-iadslargeinteger-to-int64-in-powershell/</guid><description>&lt;p&gt;&lt;img style="display: inline; float: right;" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBhQRERUPExQUFRQUFBQUFRUSFw8UFRYWFBAVFRQRFRQXGyYeFxkjGRUVHy8gJCcpLCwsFR4xNTAqNSYrLCkBCQoKDgwOGg8PGi0dHxwvLDAsLCwsLC8sKSwtKS0pKSwsLCksKSwsKSwsLCwpKSwpLCwpLCwsLCwsMSksLCkpLP/AABEIAJgAoAMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAAAwQFBgcCAQj/xABBEAABAwICBgYHBAkFAQAAAAABAAIDBBEFIQYSMUFRcRNhgZGhsRQiIzJCUpIHwdHwJENTYmOCorLCRHLS4fEX/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAIDBAUB/8QAJxEAAgIBAwMDBQEAAAAAAAAAAAECAxEEEkETITEiMlEUQmFxgTP/2gAMAwEAAhEDEQA/ANuQhCAEIXMkgaLlG8A6QmMuKAbGk+CZyY+R8A7yqXfWuSWxk0hQbdJwPeYewhO6bH4n5a1jwdkvY3Ql4YcWiRQvAbr1WkQQhCAEIQgBCEIAQhCAEIQgBCEIDieYMaXuNgBcqImrb+sd+wcAkNK6z3IQdvtH8mn1R359irk+PgnO9xuGd+S5+ou77VwXQj2yTstRdRtXiLG+89o5kX7lXaqtnlNg2S3yta7xNs0QaLTO9Z9ox15u7h96x92XJD6o0ghHxE8gfvUbPpKzc1x56oSlRo4xo2uJ4k28AohujrpZmwsJbfM7zbqU41bngk1tWS06EaSTy1BjA9iBYgnW9bK1juyv3rSVCaM6NMpIw0DPepKuxKOButI8NG6+08htK61cdkUjHJ5eRyhUrEvtHAyhiv8AvSGw+kZ+Kr1V9olWTk5jeprG/wCV1MiashY//wDSq1pvrsd1OjZbwsVK4Z9sGYbUQ5b3wk5deo7b2FAaWhN8PxCOeNs0Tg9jhcOHl1HqThACEIQAhCEAIQhAUDSOu1p5T8pDB/KPxuorR+EunDyDq2JB3X2JPFJ7mQnaZH/3FPtGqgFo4jLuK43um2zbFcFxpqYLmpgAXlPULyolurs9govcQlcxRWG5VkZ5hS9YVFUI/S4uZ8l7V70Ts9rNFqy/o3dHbX1Tq32a1srrIqzGBI8mZ7ukuQ4PDrgja2263Ba9UTajHPPwtJ7hsVHfhzZSXPa1xJuSQDmcyttlqgY4VuZTZKiI/rG/1fgmM0rNz2ntt52V6lwKIfq2fS1RtVg0fyM+lqr+oXwWdB/JSZimUzlPYpg4aCYxa3w7j2blVJpiVdCamsoqnBxfcv32S6SmKrNG4+zqAS0HY2Zgvl/uaD2gLZ18wYPWGKeGYbY54ndmuL+F19PqZAEIQgBCEIAQhCAyLGGaskrPllf/AHEplhNcY5Q34XGx57irB9omFuim9IA9SWwd1PAtnzHkqa6XY4bQbjsXInBwm0bIvKyaVBVZJR9Sq/h+Ih7A4bx/6E7NUvS8VqpVU9I8RMT4nMNnMdrjsyt25qdmnVHxqr6SQu3bByC9XkjLwbJLiomoBKPjDPEgqNp5FH4LrNwlutuMfcXZea4jrFfe/Uv0VUr0kpPIoeskSslTdMKiVZ8l5HVioFWLPcP3neavdU9QM1CwEnVBvmb57c1dTYoZyVW1ueMFdibcho2lzAOZeAF9UgL5z0Vwjp8Tgp2i7RK2R3UyP2h8gO1fRi3p5WTE1h4BCEL08BCEIAQhJVVU2Npe42A/Nh1rxvAOMQo2SxuZIAWEZ61rW4rFtJcOiilLad7nt33GQ6mu+IK94xij5sjcM3MG/rcd6rWIUWsLrn23xk8Jf0r6zXgi8MD4xe4LTnbPvT04l1FFLH6lt4yXL6dUnUre6KY8wx0U0nRyvbG0j4jbW7Uzo9BJJagtI9iHmxuDrtDsjluIUZiUOfYu8FxWaneOikc0bxtaebTkr4yiktyMVlzU2jVMYw0MoJIwPdaHfS4FUKOpVvwvS5tQwwTgNc9pZrD3TrC3Ys/keWOcw7WktPMGy9ukpYki/TSTTSJQ1KbTTpmalIyVCzmo6nkuo6scXODGNc97smtYC5zjwAG1Lultdx2BOtB6y2J079znOZ9bHAeKnFZaTIyeE2Xn7M9BXUTX1VQB6TMLauR6KO9+jvvcTYnkBuV6QhdQ5oIQhACEIQBdVDFMQMz7/A3Jo48XdqsGPT6lO8jaRq/UbKoa9gAsWpn9pVN8CcpSDm3XTnLklYCkZNpiH5fFl27ktJQuG1pC9kVowmdssYcbaw9V3Mb+0K+lKbwzRXqJVrCM+xCkcXEW2avc5p+9qTpaG2ZVtxqMekSC3+nid2iZw8ioaYJd6XtKrJOTy+RlKbJlil3e3HUJOdrB557OY60+lCXwRp6Q+rdpBDr2tyN9q8qi5vauSVVvTlkrPpC5Mu8nJWLSPA4WtMrG9HsAa0nVJJ4HZ2KrSwq22qVUtsjq1WxsW6IlU1Jf6o91OsOeY5GSt2se145tcDZN2QqTw6jLz1KNcHOSSPbJKMW2a/gulkFVkx2q/wDZvsHdm53YpoPWRw4OBYndmrLhukj4gGyEyMG85vb/AMh4ruS07SyjjxuXJeNde66jaavbI0PY4OadhH52pw2VZjQOwUJFj0sgIXS59qf+dnmqbLOrnpdTF9K7VzLS19uIac/BZ4+ouubqveU2eR4JkGVMRMvemWUqHD5FJ6NVerIWbnDxb/1dQZlXdDVakrHcHDuJsfNTrltmmCWxmW9TIeEMbe+QlRb3JxjE3tpTx6Nv0tLj5hRr5ldqv9GSl5PWR679XvVmoqYNbYBV7CszfiVYopcl29FQq6lLmRmk8shdKoC8wxN2vkPg23+SrU+GSNOqY3A8iro316+mbuaHOP8AV+AVvfTN2kBU6ilWzbydGi11xwZXQaKSOGvIOjZuv7zuoN3cyrDS4c2MWAUjV1PSPuPdGTR1ce1DI1q0+mjSs8mW++Vr/A0dEms8KmTGE0qY1o3FGCIpMRfTv12Zg++zc7r6j1q84XXiZgkYbg94O8HrColU3NSOg2I9HUvgJ9WRuuOp7LXtzafAKm+tNbkXUzae00CFpThcxuBGS6WE2ARfJU7HdBQ8mSA6pOZafd7OCuKFGUVJYZ40n5MjqsBqo9sRPW0gpg9so2xSD+Urai0FcOpmn4R3LO9LDgh00Yr0j/kf9Ll5rv8A2b/pctp9CZ8o7kehM+Udy8+kj8nnTRjlbNJI4lscmZJ91202+4BdU2A1MpsIy0He78FsQo2fKF0WAA2A2FTeni3lnvTRk2GN1QBwUs2RRFE7LPI7xwO8J82Rd2KSisGDkdYU29eD8sIt25ferBjVXqx6o2uy7N/561BYEP0ou/gj+5OMbqLy6vyjxOf4KiEfUaZPEBGFO2uyTKJyW11pMwqXprUPXRem871DB7kj6opiJujnilG54B5OyPmnc5UdivuX4WPcV61lYEXh5NNwnEb5KeCouA1F7K7wn1RyXKOkdoQhACEIQAhCEAIIQhAUnSPRhwcZoht95vHrHAqtCfPVNwRtByIWtObdQ+K6MRT7W57iMj3q+u5w7eUUzqUu5VNH3e2v/DI7pB+KQqZtaRzv3j4Zfcn40fmpXF7B0jbOAGxwvY7dh2KBdK5h9dj28wfMLRXZFtvJVZCW1IkmPSnSKNjxBvEJX01vEK/KM+By+RNpZUnJWN4hNJa9vFOwO3FMMYdaM8k5jL5Mo43O7DbvU5gug0kj2yVGQabhg2X4niq52xiiyFcmyX0Uw06jXEbQFb2i2STp6cMFglVzTeCEIQAhCEAIQhACEIQAhCEB4WpCWhY7aAhCAYzaMwu2sb3BNXaFU5+AIQgBuhNOPgCdQaMQN2Mb3BCEA/ioWN2ABLgLxCA9QhCA/9k=" alt="" width="70" height="67" align="right" /&gt;Some Active Directory attributes return an 8 byte integer in the form of an &lt;a href="file://\\LargeInteger" target="_blank"&gt;IADsLargeInteger&lt;/a&gt; interface. An example is the pwdLastSet attribute from a user object.&lt;/p&gt;
&lt;p&gt;Because the IADsLargeInteger object doesn&amp;rsquo;t provide type information PowerShell cannot read the HighPart and LowPart properties.&lt;/p&gt;
&lt;p&gt;So I wrote the function below to get the Int64 value of an IADsLargeInteger:&lt;/p&gt;</description></item><item><title>Set homefolder permissions with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/11/08/set-homefolder-permissions-with-powershell/</link><pubDate>Tue, 08 Nov 2011 21:05:19 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/11/08/set-homefolder-permissions-with-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/11/image2.webp" class="glightbox" data-type="image" data-gallery="post-2154"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 0px 0px 10px; display: inline; float: right;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/11/image_thumb2.webp" alt="image" width="77" height="66" align="right" /&gt;&lt;/a&gt;Today one of my collegues asked me to write a script that performs two actions for all users of a certain Organizational Unit:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;span style="color: #35383d;"&gt;Ensure that each user has&lt;/span&gt; modify permissions on their homefolder&lt;/li&gt;
	&lt;li&gt;Make each user visible in the Exchange Address List.&lt;/li&gt;
&lt;/ol&gt;
Sounds like a PowerShell job right?
&lt;p&gt;I reused my function to &lt;a href="https://remkoweijnen.nl/blog/2011/09/02/settings-ntfs-permissions-by-sid-in-powershell/" target="_blank"&gt;set NTFS Permissions by SID&lt;/a&gt;:&lt;/p&gt;</description></item><item><title>Construct AQS date range with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/11/04/construct-aqs-date-range-with-powershell/</link><pubDate>Fri, 04 Nov 2011 16:05:25 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/11/04/construct-aqs-date-range-with-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/11/image.webp" class="glightbox" data-type="image" data-gallery="post-2151"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 7px 0px 0px; display: inline; float: left" title="image" alt="image" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/11/image_thumb.webp" width="53" height="52" /&gt;&lt;/a&gt;For a script I needed to create an AQS (&lt;a href="http://msdn.microsoft.com/en-us/library/aa965711(v=vs.85).aspx" target="_blank"&gt;Advanced Query Syntax&lt;/a&gt;) Query that contained a date range.&lt;/p&gt; &lt;p&gt;An example of such is a range is: &lt;strong&gt;date:11/05/04..11/10/04&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;However we need to account for regional settings where for example the data seperator and the order of day and month may be different.&lt;/p&gt; &lt;p&gt;In my example I wanted to match any data that is 30 days or older so let's do this in PowerShell:&lt;/p&gt;</description></item><item><title>Exchange Move Mailbox Experiences Part 3</title><link>https://remkoweijnen.nl/blog/2011/09/28/exchange-move-mailbox-experiences-part-3/</link><pubDate>Wed, 28 Sep 2011 11:08:21 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/09/28/exchange-move-mailbox-experiences-part-3/</guid><description>&lt;p&gt;In &lt;a href="https://remkoweijnen.nl/blog/2011/09/27/exchange-move-mailbox-experiences-part-2/" target="_blank"&gt;Part 2&lt;/a&gt; I showed some details about Mailbox Rule corruptions that can disturb Mailbox Moves.&lt;/p&gt; &lt;p&gt;For this part the topic is Mailbox size, which can be an important factor in deciding which mailboxes you want to move first.&lt;/p&gt; &lt;p&gt;In my case the mailbox size was important because we agreed to move smaller mailboxes during the day but larger mailboxes only outside working hours.&lt;/p&gt; &lt;p&gt;For Exchange 2010 mailboxes it's very easy to obtain the size using PowerShell. &lt;/p&gt; &lt;p&gt;Example:&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,R2V0LU1haWxib3ggInJ3ZWlqbmVuIiB8IEdldC1NYWlsYm94U3RhdGlzdGljcyB8IHNlbGVjdCBEaXNwbGF5TmFtZSwgSXRlbUNvdW50LCBUb3RhbEl0ZW1TaXpl"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Get-Mailbox&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;rweijnen&amp;#34;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;Get-MailboxStatistics&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;select &lt;/span&gt;&lt;span class="n"&gt;DisplayName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ItemCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TotalItemSize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table border="0" cellspacing="10" cellpadding="2" width="430"&gt;&lt;tbody&gt;
 &lt;tr&gt;
 &lt;td valign="top" width="130"&gt;DisplayName&lt;/td&gt;
&lt;pre&gt;&lt;code&gt; &amp;lt;td valign=&amp;quot;top&amp;quot; width=&amp;quot;70&amp;quot; align=&amp;quot;right&amp;quot;&amp;gt;ItemCount&amp;lt;/td&amp;gt;

 &amp;lt;td valign=&amp;quot;top&amp;quot; width=&amp;quot;230&amp;quot; align=&amp;quot;right&amp;quot;&amp;gt;TotalItemSize&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
 &amp;lt;td valign=&amp;quot;top&amp;quot; width=&amp;quot;130&amp;quot;&amp;gt;Remko Weijnen&amp;lt;/td&amp;gt;

 &amp;lt;td valign=&amp;quot;top&amp;quot; width=&amp;quot;70&amp;quot; align=&amp;quot;right&amp;quot;&amp;gt;313&amp;lt;/td&amp;gt;

 &amp;lt;td valign=&amp;quot;top&amp;quot; width=&amp;quot;230&amp;quot; align=&amp;quot;right&amp;quot;&amp;gt;34.87 MB (36,564,183 bytes&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
 &lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;But how can we get the Mailbox Size for Exchange 2003 mailboxes?&lt;/p&gt;
&lt;p&gt;&amp;#160;&lt;/p&gt;</description></item><item><title>Inline arrays in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/09/28/inline-arrays-in-powershell/</link><pubDate>Wed, 28 Sep 2011 10:34:18 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/09/28/inline-arrays-in-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/09/image28.webp" class="glightbox" data-type="image" data-gallery="post-2119"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px 0px 0px 16px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/09/image_thumb28.webp" alt="image" width="119" height="79" align="right" border="0" /&gt;&lt;/a&gt;Sometimes I want to process a list of &amp;ldquo;things&amp;rdquo; easily in PowerShell where the list is not in an external file but in the script itself.&lt;/p&gt;
&lt;p&gt;Ideally this list would not be separated by e.g. a comma so it can be easily copy/pasted from external data sources.&lt;/p&gt;
&lt;p&gt;Something like this:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,JExpc3QgPSBAKCIKSm9obiBEb2UKSmFuZSBEb2UKSmFtZXMgQm9uZApBbmQgc28gdGhlIGxpc3QgZ29lcyBvbgoiKQ=="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$List&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="vm"&gt;@&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;John Doe
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;Jane Doe
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;James Bond
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;And so the list goes on
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;</description></item><item><title>Settings NTFS Permissions by SID in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/09/02/settings-ntfs-permissions-by-sid-in-powershell/</link><pubDate>Fri, 02 Sep 2011 17:21:42 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/09/02/settings-ntfs-permissions-by-sid-in-powershell/</guid><description>&lt;p&gt;&lt;img style="margin: 0px 0px 0px 10px" align="right" src="http://t0.gstatic.com/images?q=tbn:ANd9GcTPzlU95MOmfR0YwGb55TQkoZENCxgxFUKqp6qqfMMaa9skPMT5gw" width="60" height="47" /&gt;I am currently creating a PowerShell script that creates a user with all needed Active Directory attributes, Exchange mailbox, (TS) Home- and Profile directories and so on.&lt;/p&gt; &lt;p&gt;In such a script you can easily get failures because of Active Directory replication. &lt;br /&gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Check if a useraccount exists with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/09/02/check-if-a-useraccount-exists-with-powershell/</link><pubDate>Fri, 02 Sep 2011 11:51:37 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/09/02/check-if-a-useraccount-exists-with-powershell/</guid><description>&lt;p&gt;Function below can be used to check if a given Username exists in Active Directory:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,ZnVuY3Rpb24gVXNlckV4aXN0cyhbc3RyaW5nXSRVc2VybmFtZSkKewoJJHN0ckZpbHRlciA9ICIoJihvYmplY3RDYXRlZ29yeT1wZXJzb24pKHNBTUFjY291bnROYW1lPSRVc2VybmFtZSkpIgoKCSRvYmpEb21haW4gPSBOZXctT2JqZWN0IFN5c3RlbS5EaXJlY3RvcnlTZXJ2aWNlcy5EaXJlY3RvcnlFbnRyeQoKCSRvYmpTZWFyY2hlciA9IE5ldy1PYmplY3QgU3lzdGVtLkRpcmVjdG9yeVNlcnZpY2VzLkRpcmVjdG9yeVNlYXJjaGVyCgkkb2JqU2VhcmNoZXIuU2VhcmNoUm9vdCA9ICRvYmpEb21haW4KCSRvYmpTZWFyY2hlci5QYWdlU2l6ZSA9IDEwMDAKCSRvYmpTZWFyY2hlci5GaWx0ZXIgPSAkc3RyRmlsdGVyCgkkb2JqU2VhcmNoZXIuU2VhcmNoU2NvcGUgPSAiU3VidHJlZSIKCgkkY29sUmVzdWx0cyA9ICRvYmpTZWFyY2hlci5GaW5kQWxsKCkKCXJldHVybiBbYm9vbF0oJGNvbFJlc3VsdHMgLW5lICRudWxsKQp9"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;UserExists([string]$Username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$strFilter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;(&amp;amp;(objectCategory=person)(sAMAccountName=&lt;/span&gt;&lt;span class="nv"&gt;$Username&lt;/span&gt;&lt;span class="s2"&gt;))&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objDomain&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;New-Object&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;DirectoryServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;DirectoryEntry&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objSearcher&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;New-Object&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;DirectoryServices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;DirectorySearcher&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objSearcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;SearchRoot&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$objDomain&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objSearcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;PageSize&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objSearcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;Filter&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$strFilter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$objSearcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;SearchScope&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Subtree&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="nv"&gt;$colResults&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$objSearcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;FindAll&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;	&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="nv"&gt;$colResults&lt;/span&gt; &lt;span class="o"&gt;-ne&lt;/span&gt; &lt;span class="vm"&gt;$null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;</description></item><item><title>Get smallest Exchange Database in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/08/16/get-smallest-exchange-database-in-powershell/</link><pubDate>Tue, 16 Aug 2011 14:16:33 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/08/16/get-smallest-exchange-database-in-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c.webp"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 10px 0px 0px" title="SNAGHTML1ca684c" border="0" alt="SNAGHTML1ca684c" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c_thumb.webp" width="49" height="49" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I needed to adapt some scripts that create a user with mailbox for Exchange 2010. The existing scripts had a hardcoded database for new mailboxes.&lt;/p&gt; &lt;p&gt;I wanted the mailbox to be created in the smallest database, but how do we determine this?&lt;/p&gt;</description></item><item><title>Set Exchange Product Key with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/08/15/set-exchange-product-key-with-powershell/</link><pubDate>Mon, 15 Aug 2011 09:17:14 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/08/15/set-exchange-product-key-with-powershell/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c.webp"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 10px 0px 0px" title="SNAGHTML1ca684c" border="0" alt="SNAGHTML1ca684c" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c_thumb.webp" width="49" height="49" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;By default Exchange 2007 and 2010 are installed in Trial mode so before going into production you need to enter the Product Key.&lt;/p&gt; &lt;p&gt;The Exchange Management Console will warn you if one or more servers are still in trial mode:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/08/image.webp" class="glightbox" data-type="image" data-gallery="post-1985"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/08/image_thumb.webp" width="419" height="246" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>PowerShell script to set Exchange Static RPC Ports</title><link>https://remkoweijnen.nl/blog/2011/08/10/powershell-script-to-set-exchange-static-rpc-ports/</link><pubDate>Wed, 10 Aug 2011 16:49:01 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/08/10/powershell-script-to-set-exchange-static-rpc-ports/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c.webp"&gt;&lt;img loading="lazy" decoding="async" style="margin: 0px 10px 0px 0px" title="SNAGHTML1ca684c" border="0" alt="SNAGHTML1ca684c" align="left" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c_thumb.webp" width="49" height="49" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I am currently working on an Exchange migration from 2003 to 2010. For the implementation of a load balancing solution for the CAS/HUB servers I needed to set Static RPC Ports for the &lt;em&gt;RPC Client Access Service&lt;/em&gt; and the &lt;em&gt;Exchange Address Book Service&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;The procedure of changing these ports is described on the Technet Wiki: &lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/configure-static-rpc-ports-on-an-exchange-2010-client-access-server.aspx" target="_blank"&gt;Configure Static RPC Ports on an Exchange 2010 Client Access Server&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;img alt="" align="right" src="http://t0.gstatic.com/images?q=tbn:ANd9GcTPzlU95MOmfR0YwGb55TQkoZENCxgxFUKqp6qqfMMaa9skPMT5gw" width="66" height="52" /&gt;Since I am lazy I decided to do this with a PowerShell script that would automatically do this for all CAS/HUB servers in my 2010 environment.&lt;/p&gt;</description></item><item><title>AD Internals: Display RID Allocation Pools</title><link>https://remkoweijnen.nl/blog/2011/06/27/ad-internals-display-rid-allocation-pools/</link><pubDate>Mon, 27 Jun 2011 15:37:04 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/06/27/ad-internals-display-rid-allocation-pools/</guid><description>&lt;p&gt;In my previous post I wrote about a problem I had with duplicate RID Allocation pools. &lt;/p&gt; &lt;p&gt;But how do we get more insight into these RID Allocation pools?&lt;/p&gt; &lt;p&gt;The DCDIAG tool can display this information per domain controleler using the following syntax&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;batch&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".bat" href="data:text/plain;charset=utf-8;base64,ZGNkaWFnIC9zOnNlcnZlciAvdiAvdGVzdDpyaWRtYW5hZ2Vy"&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-batch" data-lang="batch"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dcdiag /s:server /v /test:ridmanager&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Example output:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image28.webp" class="glightbox" data-type="image" data-gallery="post-1950"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="DCDiag Ridmanager Test" border="0" alt="DCDiag Ridmanager Test" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image_thumb28.webp" width="419" height="85" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But where in Active Directory is this information stored and can we display it for all Domain Controllers at once for larger environments?&lt;/p&gt;</description></item><item><title>Exchange 2010 well-known object entry install error</title><link>https://remkoweijnen.nl/blog/2011/06/24/exchange-2010-well-known-object-entry-install-error/</link><pubDate>Fri, 24 Jun 2011 12:52:30 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/06/24/exchange-2010-well-known-object-entry-install-error/</guid><description>&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c.webp" class="glightbox" data-type="image" data-gallery="post-1921"&gt;&lt;img loading="lazy" decoding="async" style="border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="SNAGHTML1ca684c" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/SNAGHTML1ca684c_thumb.webp" border="0" alt="SNAGHTML1ca684c" width="49" height="49" align="left" /&gt;&lt;/a&gt;Today I was testing the installation of Exchange 2010 in a VMWare sandbox environment. We created the sandbox to test migration from a 2003 AD and Exchange environment to 2008 R2 with Exchange 2010.&lt;/p&gt;
&lt;p&gt;We used a P2V to get real copies of the Active Directory and the AD upgrade to 2008 R2 was already tested.&lt;/p&gt;
&lt;p&gt;But during the Exchange installation in the sandbox I got the following error:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image16.webp" class="glightbox" data-type="image" data-gallery="post-1921"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Exchange Server 2010 Setup Error" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image_thumb16.webp" border="0" alt="The well-known object entry on the otherWellKnownObjects attribute in the container object CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=zorg,DC=local points to an invalid DN or a deleted object. Remove the entry, and then rerun the task." width="429" height="366" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Reading the otherWellKnownObjects attribute with PowerShell</title><link>https://remkoweijnen.nl/blog/2011/06/24/reading-the-otherwellknownobjects-attribute-with-powershell/</link><pubDate>Fri, 24 Jun 2011 11:19:25 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/06/24/reading-the-otherwellknownobjects-attribute-with-powershell/</guid><description>&lt;p&gt;I wanted to read the &lt;a href="http://msdn.microsoft.com/en-us/library/ms679095(v=vs.85).aspx" target="_blank"&gt;otherWellKnownObjects&lt;/a&gt; attribute from an Active Directory object.&lt;/p&gt; &lt;p&gt;In my case this was the Microsoft Exchange container in the Configuration partition:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image14.webp" class="glightbox" data-type="image" data-gallery="post-1899"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image_thumb14.webp" width="243" height="317" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The otherWellKnownObjects attribute is of type ADSTYPE_DN_WITH_BINARY which unfortunately cannot be viewed or edited with ADSI Edit:&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image15.webp" class="glightbox" data-type="image" data-gallery="post-1899"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ADSI Edit" border="0" alt="There is no editor registered to handle this attribute type" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/06/image_thumb15.webp" width="381" height="149" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;p&gt;&amp;#160;&lt;/p&gt;</description></item><item><title>SSL Certificates in termsrv.dll</title><link>https://remkoweijnen.nl/blog/2011/05/02/ssl-certificates-in-termsrv-dll/</link><pubDate>Mon, 02 May 2011 14:54:39 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/05/02/ssl-certificates-in-termsrv-dll/</guid><description>&lt;p&gt;I was digging around in termsrv.dll yesterday when I noticed that there are some (well 372 to be exact) SSL certificates inside the Terminal Server binary (termsrv.dll):&lt;/p&gt; &lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/05/image7.webp" class="glightbox" data-type="image" data-gallery="post-1726"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb7.webp" width="416" height="195" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Two of them seem to actually contain the private keys as well, but I am not 100% sure it may be just a certificate in another format.&lt;/p&gt; &lt;p&gt;&amp;#160;&lt;/p&gt;</description></item><item><title>The Case of the Citrix Ready Printer Driver</title><link>https://remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/</link><pubDate>Tue, 08 Feb 2011 21:47:44 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/</guid><description>&lt;p&gt;I had a very interesting issue today on a new Citrix XenApp 5 farm. We went into production yesterday and we noticed a number of issues:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;span style="color: #35383d;"&gt;Printing in general was slow, especially when a user connects to a printer for the first time.&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;User Profiles were rapidly growing in size (from the expected 1-2 MB to over 40 MB).&lt;/li&gt;
	&lt;li&gt;Logons took much longer then in the testing period (and since we use a Full Screen Desktop the user doesn't see any progress).&lt;/li&gt;
	&lt;li&gt;Performance monitoring showed CPU spikes in Word, Excel and IE processes.&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="color: #4c4c4c;"&gt;I took a look at the profiles first and noticed that the size growth was due to a Xerox subfolder in %APPDATA%:</description></item><item><title>Get last char of the computername in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/02/01/get-last-char-of-the-computername-in-powershell/</link><pubDate>Tue, 01 Feb 2011 10:02:20 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/02/01/get-last-char-of-the-computername-in-powershell/</guid><description>&lt;p&gt;For my &lt;a href="https://remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/" target="_blank"&gt;Reboot Script&lt;/a&gt; I needed to get the last character of the computername and convert it to an integer.&lt;/p&gt; &lt;p&gt;We can do it like this in PowerShell:&lt;/p&gt; 
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,JGkgPSBbaW50XSIkKChnYyBlbnY6Y29tcHV0ZXJuYW1lKVstMV0pIg=="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;$((&lt;/span&gt;&lt;span class="nb"&gt;gc &lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="n"&gt;computername&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mf"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;</description></item><item><title>PowerShell Script to add reboot scheduled task for Citrix</title><link>https://remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/</link><pubDate>Mon, 31 Jan 2011 22:53:47 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/</guid><description>&lt;p&gt;I wanted to create a Scheduled Task on my Citrix Servers to have the reboot every other night.&lt;/p&gt;
&lt;p&gt;The idea is that half of the servers will reboot in a night and the other half the following night.&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://support.microsoft.com/kb/320188" target="_blank"&gt;TSSHUTDN&lt;/a&gt; tool is handy since it can issue a warning to logged on users, log them out after a certain period and finally issue the reboot.&lt;/p&gt;
&lt;p&gt;Since I needed to add a scheduled task to many servers I wanted to do this with a script.&lt;/p&gt;
&lt;p&gt;WMI Exposes the &lt;a href="http://msdn.microsoft.com/en-us/library/aa394399(v=VS.85).aspx" target="_blank"&gt;Win32_ScheduledJob&lt;/a&gt; Class and it&amp;rsquo;s &lt;a href="http://msdn.microsoft.com/en-us/library/aa389389(v=vs.85).aspx" target="_blank"&gt;Create Method&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>PowerShell Script to raise Citrix Video Memory</title><link>https://remkoweijnen.nl/blog/2011/01/28/powershell-script-to-raise-citrix-video-memory/</link><pubDate>Fri, 28 Jan 2011 15:23:08 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/28/powershell-script-to-raise-citrix-video-memory/</guid><description>&lt;p&gt;On a Citrix XenApp 5 environment a user reported that he was unable to start a Full Screen session on a Dual Monitor Configuration.&lt;/p&gt;
&lt;p&gt;He received this error message:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1316" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/foutmelding-2.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="foutmelding (2)" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/foutmelding-2_thumb.webp" border="0" alt="foutmelding (2)" width="244" height="78" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Enabling Privileges for WMI in PowerShell</title><link>https://remkoweijnen.nl/blog/2011/01/27/enabling-privileges-for-wmi-in-powershell/</link><pubDate>Thu, 27 Jan 2011 11:05:30 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/27/enabling-privileges-for-wmi-in-powershell/</guid><description>&lt;p&gt;A few days ago I wrote about a &lt;a href="https://remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/"&gt;PowerShell Script to Install Printer Drivers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I noticed there was a problem with this script: some drivers fail to load with error 1797 which means &lt;a href="http://msdn.microsoft.com/en-us/library/ms681386(v=vs.85).aspx" target="_blank"&gt;ERROR_UNKNOWN_PRINTER_DRIVER&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I reread the &lt;a href="http://msdn.microsoft.com/en-us/library/aa384769(v=vs.85).aspx" target="_blank"&gt;AddPrinterConnection&lt;/a&gt; documentation on MSDN but it didn&amp;rsquo;t mention anything about additional required permissions or anything.&lt;/p&gt;</description></item><item><title>Script to install all print drivers on Citrix or Terminal Server</title><link>https://remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/</link><pubDate>Tue, 25 Jan 2011 15:24:14 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/</guid><description>&lt;p&gt;I wrote a PowerShell script to install all printer drivers on a Citrix or Terminal Server.&lt;/p&gt;
&lt;p&gt;Actually the script isn&amp;rsquo;t specific to Citrix or Terminal Server but on such environments we need to preload all drivers because users do not have the permissions to do that.&lt;/p&gt;
&lt;p&gt;I have chosen for PowerShell because you can do it in a one-liner which makes it easy to run this script from my Altiris server on all Citrix Servers.&lt;/p&gt;
&lt;p&gt;The idea is that we enumerate all the shared printers on a Printer Server and make a connection to each printer. This will make sure that the driver is installed if it wasn&amp;rsquo;t already present.&lt;/p&gt;
&lt;p&gt;The script could even be scheduled to enforce that newly added printer drivers are added to each Citrix Server.&lt;/p&gt;</description></item><item><title>Adding a hidden Exchange mailbox to Outlook</title><link>https://remkoweijnen.nl/blog/2011/01/25/adding-a-hidden-exchange-mailbox-to-outlook/</link><pubDate>Tue, 25 Jan 2011 13:11:42 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/25/adding-a-hidden-exchange-mailbox-to-outlook/</guid><description>&lt;p&gt;In Exchange it&amp;rsquo;s possible to hide a Mailbox from the (Global) Address List. You can do that in the Exchange System Manager:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1286" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image13.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb13.webp" border="0" alt="image" width="207" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But after you have hidden a Mailbox you cannot create an Outlook profile for it (or add it as an extra mailbox).&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1286" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image14.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb14.webp" border="0" alt="image" width="244" height="188" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When you click Check Name in the wizard you&amp;rsquo;ll get an error:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1286" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image15.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb15.webp" border="0" alt="image" width="244" height="95" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The common workaround is to remove the &amp;ldquo;&lt;em&gt;Hide from Exchange address lists&lt;/em&gt;&amp;rdquo; setting, create the profile (or add the Mailbox) and afterwards set it again.&lt;/p&gt;
&lt;p&gt;Once the profile is created it all keeps working.&lt;/p&gt;
&lt;p&gt;There is an easier solution though!&lt;/p&gt;</description></item><item><title>Recursive Groups #2</title><link>https://remkoweijnen.nl/blog/2011/01/18/recursive-groups-2/</link><pubDate>Tue, 18 Jan 2011 19:51:15 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/18/recursive-groups-2/</guid><description>&lt;p&gt;In my &lt;a href="https://remkoweijnen.nl/blog/2011/01/18/recursive-group-membership-in-powershell/"&gt;previous post&lt;/a&gt; I explained how to get the recursive group membership with a very simple Powershell Script.&lt;/p&gt;
&lt;p&gt;Commenter Michel thought that the script only tested one level deep but it doesn&amp;rsquo;t.&lt;/p&gt;
&lt;p&gt;But let&amp;rsquo;s prove that!&lt;/p&gt;
&lt;p&gt;Create 3 Global Groups in your Active Directory and name them Level1, 2 and 3:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1234" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image2.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb2.webp" border="0" alt="image" width="244" height="48" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Make Level3 a Member of Level 2 and make Level a member of Level 1 and finally add an account to the Level 3 group:&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1234" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image3.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb3.webp" border="0" alt="image" width="244" height="81" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1234" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image4.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb4.webp" border="0" alt="image" width="244" height="77" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="glightbox" data-type="image" data-gallery="post-1234" href="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image5.webp"&gt;&lt;img loading="lazy" decoding="async" style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/image_thumb5.webp" border="0" alt="image" width="244" height="79" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Recursive group Membership in Powershell</title><link>https://remkoweijnen.nl/blog/2011/01/18/recursive-group-membership-in-powershell/</link><pubDate>Tue, 18 Jan 2011 12:54:17 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2011/01/18/recursive-group-membership-in-powershell/</guid><description>&lt;p&gt;In this post I will show an easy way to get the recursive group membership for the current user.&lt;/p&gt;
&lt;p&gt;I use this in a logon script to handle certain tasks based on group membership.&lt;/p&gt;
&lt;p&gt;Most scripts I see for this task do a manual recursive enumeration but in a large environment this could be very slow.&lt;/p&gt;
&lt;p&gt;A better way would be to use the &lt;a href="http://msdn.microsoft.com/en-us/library/ms680275(v=vs.85).aspx" target="_blank"&gt;tokenGroups&lt;/a&gt; attribute of the Active Directory user object.&lt;/p&gt;
&lt;p&gt;The tokenGroups attribute is an array of SIDs computed by Active Directory and is used to verify user access.&lt;/p&gt;
&lt;p&gt;We need to translate these SIDs to their sAMAccountNames to get the actual group names.&lt;/p&gt;
&lt;p&gt;In unmanaged code this could be accomplished by calling the &lt;a href="http://msdn.microsoft.com/en-us/library/ms675970(VS.85).aspx" target="_blank"&gt;DsCrackNames&lt;/a&gt; API or the &lt;a href="http://msdn.microsoft.com/en-us/library/aa706046(v=VS.85).aspx" target="_blank"&gt;IADsNameTranslate&lt;/a&gt; interface.&lt;/p&gt;
&lt;img width="1" height="1" loading="lazy" decoding="async" title="More..." src="https://remkoweijnen.nl/blog/wp-content/uploads/2011/01/trans.gif" alt="" /&gt;</description></item><item><title>Packaging an application – Auto Accept the EULA</title><link>https://remkoweijnen.nl/blog/2010/12/17/packaging-an-application-auto-accept-the-eula/</link><pubDate>Fri, 17 Dec 2010 17:10:03 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2010/12/17/packaging-an-application-auto-accept-the-eula/</guid><description>&lt;p&gt;Yesterday I was packaging an application called Kluwer Juridische Bibliotheek. When the user first starts this application a screen with the License Conditions pops up and it must be accepted:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://remkoweijnen.nl/blog/wp-content/uploads/2010/12/kluwereula.webp" class="glightbox" data-type="image" data-gallery="post-879"&gt;&lt;img loading="lazy" decoding="async" src="https://remkoweijnen.nl/blog/wp-content/uploads/2010/12/kluwereula-small.webp" alt="KluwerEULA" width="430" height="399" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I always try to remove such things as I don&amp;rsquo;t think it&amp;rsquo;s necessary for every user to accept it.&lt;/p&gt;</description></item><item><title>Writing Environment Variables to the Registry from a Script</title><link>https://remkoweijnen.nl/blog/2010/12/13/writing-environment-variables-to-the-registry-from-a-script/</link><pubDate>Mon, 13 Dec 2010 20:52:59 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2010/12/13/writing-environment-variables-to-the-registry-from-a-script/</guid><description>&lt;p&gt;I usually change the text below the &amp;ldquo;This Computer&amp;rdquo; icon to reflect the current username and servername:&lt;/p&gt;
&lt;img loading="lazy" decoding="async" src="https://remkoweijnen.nl/blog/wp-content/uploads/2010/12/useroncomputer.webp" alt="UserOnComputer" width="86" height="83" /&gt;
&lt;p&gt;This is an ancient trick, just set the the &lt;em&gt;LocalizedString&lt;/em&gt; Value of the following key:&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;batch&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".bat" href="data:text/plain;charset=utf-8;base64,SEtFWV9DTEFTU0VTX1JPT1RcQ0xTSURcezIwRDA0RkUwLTNBRUEtMTA2OS1BMkQ4LTA4MDAyQjMwMzA5RH0="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-batch" data-lang="batch"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;to &amp;ldquo;%USERNAME% on %COMPUTERNAME%&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;It get&amp;rsquo;s a little more complicated if you want to set this from a script, because the environment variables are replaced with the actual value BEFORE they are entered in the Registry.&lt;/p&gt;</description></item><item><title>Citrix Web Interface starts very slowly</title><link>https://remkoweijnen.nl/blog/2010/11/26/citrix-web-interface-starts-very-slowly/</link><pubDate>Fri, 26 Nov 2010 15:07:45 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2010/11/26/citrix-web-interface-starts-very-slowly/</guid><description>&lt;p&gt;I remembered from a previous project that when the Citrix Web Interface this is caused by a setting called &lt;em&gt;generatePublisherEvidence&lt;/em&gt; in the Aspnet.config file.&lt;/p&gt;
&lt;p&gt;This behaviour has been documented by Citrix in &lt;a title="Web Interface 5.x Delay on First Page" href="http://support.citrix.com/article/ctx117273" target="_blank"&gt;CTX117273&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you read it carefully you will see the note that you need to fix it in 2 places for an x64 system.&lt;/p&gt;</description></item><item><title>PowerShell 2.0: Changing password through ADSI problem</title><link>https://remkoweijnen.nl/blog/2009/11/24/powershell-2-0-changing-password-through-adsi-problem/</link><pubDate>Tue, 24 Nov 2009 11:50:08 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2009/11/24/powershell-2-0-changing-password-through-adsi-problem/</guid><description>&lt;p&gt;I needed to do a mass password change on imported accounts and decided to do this with Powershell. For some reason (maybe because I am using PowerShell 2.0) I got an unexpected error when using the Password property or the SetPassword method (RandomPassword is a function I wrote that generates Random passwords the meet the Complexity Requirements):&lt;/p&gt;
&lt;div class="codecard"&gt;
 &lt;div class="codehead"&gt;
 &lt;span class="codefile"&gt;&lt;/span&gt;
 &lt;span class="codetools" data-pagefind-ignore&gt;
 &lt;span class="codelang"&gt;powershell&lt;/span&gt;
 &lt;button class="codebtn" type="button" data-copy&gt;Copy&lt;/button&gt;
 &lt;a class="codebtn" download=".ps1" href="data:text/plain;charset=utf-8;base64,JHVzZXIuUGFzc3dvcmQgPSBSYW5kb21QYXNzd29yZAokdXNlci5Db21taXRDaGFuZ2VzKCk="&gt;Download&lt;/a&gt;
 &lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="codebody"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;Password&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RandomPassword&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;CommitChanges&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;</description></item><item><title>Removing Public Folder Replicas in Exchange 2007</title><link>https://remkoweijnen.nl/blog/2009/11/11/removing-public-folder-replicas-in-exchange-2007/</link><pubDate>Wed, 11 Nov 2009 15:47:35 +0000</pubDate><guid>https://remkoweijnen.nl/blog/2009/11/11/removing-public-folder-replicas-in-exchange-2007/</guid><description>&lt;p&gt;When you uninstall Exchange 2007 you need to remove all Mailbox- and Public Folder databases. If you try to remove the Public Folder Database this will fail because there are replicas of the system folders in the Public Folder database. I didn&amp;rsquo;t find a way to remove these replicas from the Exchange Management GUI but it can be done with the following Powershell Code:&lt;/p&gt;</description></item></channel></rss>