PowerShell – Create a Directory (Path/Folder) If It Doesn’t Exit

Frequently in PowerShell, we need to add a directory if it doesn’t already exist. Simple Code – Check If the Directory Exists First This assumes the higher level directories exist, and you just want to add the lowest level directory: <pre> $targetFilePath = "e:\Dropbox\Audios\Album\Sinatra" if (!(Test-Path $targetFilePath))   {      New-Item -ItemType Directory -Path $targetFilePath | […]

How to put ASCII decimal/hex values in an XML file

For example, to put a pound (or hash) sign # in an XML file, you can use either of the following: ASCII decimal and Hex values in XML <pre> &#35; or &#x23; </pre> 23 in hex = 2×16+3 = 35 in decimal So the syntax is the ampersand and the hash tag followed by the […]

Error running Saxonica query.exe (content item for axis step is absent)

Query.exe is the implementation of the Saxon XQuery command/engine. It’s a command line program that I’m running from the Windows command prompt. Issue <pre> C:\XMLClass\XQuery>c:\Saxonica\bin\Query.exe -q:Flight3_Xquery.txt -o:flight3_xquery_out.xml Error on line 2 column 20 of Flight3_Xquery.txt:   XPDY0002: The context item for axis step root/descendant::FlightLeg is absent Query failed with dynamic error: The context item for axis […]

Generate a Schema from an XML File in PowerShell

While BizTalk includes an XML to XSD schema utility, we can do the same thing in C# or PowerShell (version 5.1 used in this example, but most of the work is done by .Net classes). The .NET System.Xml libraries include something interesting called the XmlSchemaInference object.  It can basically look at the XML data file, […]

BizTalk Pipeline Editor Shows Same Component Twice

Today, I was driven crazy by the Pipeline Editor in Visual Studio. I dropped two different pipeline components in it, then when I closed and re-opened it they would show the same name. When I opened the .btp file in a text editor it looked okay. So it was apparently a problem displaying the user […]

C# Send Email (with \r\n Line Breaks for Non-HTML or
for HTML

The .NET System.Message class allow for isHTMLBody to be true or false. Setting to true allows you to use HTML to make fields bolds, to use headers, to change colors, fonts, etc… But sometimes you prefer just a text email. In an HTML email, you cna use (break HTML) to create new lines. In a […]

How to Schedule a PowerShell Script in Windows Task Scheduler

NOTE: I highly recommend that you create a folder in Task Scheduler for your company name. Do not mix your scheduled tasks with those that are there under various Windows features. Open Windows “Task Scheduler”, and create a task. Give it a name and a schedule. The part most people have questions about is the […]

PowerShell – Find top X Largest Files on Disk

Frequently, we get monitor alerts that the disk is under 20% full. The question is usually what files are large that can be deleted. I often use the fantastic utility WinDirStat. And there are PowerShell commands to show you the top files on the disk. But typically, some of the largest files are the paging […]

BizTalk Receive Location Duplicator in PowerShell

How do you create an identical copy of a BizTalk ReceiveLocation within a Receive Port? Well, it cannot be 100% identical. The name will of course have to change, the URI will have to be unique as well. I recently had a case where we wanted the same orchestration to run on two different databases […]

BizTalk SendPort Duplicator in PowerShell

How do you create an identical copy of a BizTalk SendPort except for the name? It’s not uncommon for me to want create a duplicate of a SendPort, especially if it’s a more complicated SendPort like WCF or SQL with lots of parameters. I finally wrote a PowerShell to do this. Maybe later, I’ll do […]