Category Archives: PowerShell

PowerShell: solid password generator

I needed a PowerShell script to generate a random alpha-numeric string. Here were my goals: The randomness needs to be cryptographically strong. Having at least some characters of different types is not a concern here. Small-ish, readable code is a … Continue reading

Posted in PowerShell, Programming | 5 Comments

Script to turn on "Treat Warnings as Errors"

This PowerShell script recursively finds all .csproj files in a directory and sets “Treat warnings as errors” to “All” for every one of them that doesn’t already have it set. I definitely prefer this compilation option, but on larger systems … Continue reading

Posted in PowerShell, Programming | Leave a comment

Call a web service with PowerShell

I recently used a PowerShell script like the following to troubleshoot the details of a third-party web service our code was using. I thought the script was something worth noting here for future reference. $url = <span class="str">"https://path/to/Service.asmx"</span> $parameters = … Continue reading

Posted in PowerShell, REST | 3 Comments

Write MSMQ Messages from PowerShell

This PowerShell script sends a message to an MSMQ. I did it this particular way because NServiceBus can consume messages sent like this. [Reflection.Assembly]::LoadWithPartialName("System.Messaging"); $queueName = '.\Private$\your.queue.name'; $queue = new-object System.Messaging.MessageQueue $queueName; $utf8 = new-object System.Text.UTF8Encoding; $tran = new-object System.Messaging.MessageQueueTransaction; … Continue reading

Posted in CodeMinder, MSMQ, PowerShell, Programming | 5 Comments

Read MSMQ Messages from PowerShell

This script dumps the contents of an MSMQ to the console. This one dumps the Journal contents of a private queue; of course you’ll have to adjust that line for your queue. [Reflection.Assembly]::LoadWithPartialName(<span class="str">"System.Messaging"</span>) $queueName = <span class="str">'.\Private$\your.queue.name\Journal$'</span>; $queue = … Continue reading

Posted in CodeMinder, MSMQ, PowerShell, Programming | Leave a comment