Community Blogs

Browse by Tags

Related Posts

  • PowerShell: Keeping Secrets for Batch Scripts

    As a system administrator, I write a lot of utility scripts, and I love using PowerShell. However, I cannot always use the local scheduler with a service account to run a script, sometimes I have to provide a username and password to an application or service. I hate storing them in plaintext, and while I don't fully like storing the encrypted text, key, and IV in the script, it is one step better than the plaintext solution. While the ultimate solution would be to have it stored as part of the user profile for the job, this is an issue when I don't have direct access to the production system to be able to run as the service account and I just need an encrypted file / text to later decrypt and use. So, I started working with ConvertTo...


  • PowerShell: Adding the Using Statement

    So, I happened to come across a need for the using statement from C#. I basically didn't want to use Try...Finally when I am so used to the short-hand using statement. Thank goodness I already have a Try..Catch..Finally statement/function for PowerShell, I can just use that existing framework and make a using statement/function pretty easily. function Using { param ( [System.IDisposable] $inputObject = $(throw "The parameter -inputObject is required."), [ScriptBlock] $scriptBlock = $(throw "The parameter -scriptBlock is required.") ) Try { &$scriptBlock } -Finally { if ($inputObject -ne $null) { $inputObject.Dispose() } } } # Short example ... Using ($user = $sr.GetDirectoryEntry()) { $user.displayName = $displayName...


  • Top 5 Secrets of .Net Desktop Deployment Wizards

    Deployment is one of the software project taxes that are often neglected or shunted aside to have another team deal with. There are two big downsides when a team does not directly own it's deployment. The first is obvious, if the quality of the deployment infrastructure isn't any good, users perception of your software will suffer. Rightfully so, any you find yourself spending time fixing bugs that are only tangential to your project. The second risk has to do with how outsourcing (to another group, another department or other company) deployment infrastructure can affect your project. If the amount of time it takes to get a new deployment ready is more than an hour - you'll find yourself adjusting the release schedule to accommodate...


  • PowerShell Navigation Provider for Coral8

    A couple of months ago I put together a quick PowerShell based stream reader for Coral8 . While it was fun to write, beyond demos, it didn't see much use - lack of easy discoverability about which streams were available meant that it was easier to use the Coral8 studio. So today I have a fix for that, a Coral8 navigation provider. Although it's not nearly fully featured, it's enough to get started. This implementation takes advantage of the previous PowerShell script to do much of its work. Although it's interesting to see how easy it is to "shell out" to augment the capabilities of c#, I don't see myself doing much more of that style of coding in the future, as debugging the scripts from within C# is too difficult...


  • C:\Program Files\Reference Assemblies for assemblies to reference in your code

    I just stumbles across a "new" concept of Microsoft. In the C:\Program Files\Reference Assemblies folder Microsoft installs assemblies for products that can be referenced from your code. Instead of referencing assemblies directly from the GAC or copying an assembly from an installation folder or the GAC to your project for reference, you can now reference the assemblies in this folder. We have a similar approach in our Macaw Solutions Factory where we have a _SharedAssemblies folder to keep track of all external assemblies to reference. We prefer to keep the assemblies with the source that is checked into source control, because otherwise it is possible that a build server does not contain the expected assemblies when compiling a checked...


  • New IIS7 Releases: URL Rewrite, Application Routing and Load Balancing, and PowerShell Cmd-lets

    In last a few weeks, the IIS team has released 3 IIS extensions updates: · URL Rewrite Module CTP1 · Application Request Routing CTP1 · PowerShell Provider CTP2 URL Rewrite Module URL Rewrite Module is a rule-based rewriting engine for changing request URL’s before they get processed by web server.  It can be used to provide user and search engine friendly URLs for dynamic web applications, rewrite and redirect URLs based on HTTP headers and server variables, and control...( read more ) Read More...


  • Coral8 Stream reader in Powershell

    A little something I cooked up last night # ./Get-C8Tuple ccl://localhost:6789/Stream/Default/Proj/outStream param ([string]$curl,[int]$maxRows=-1) function Resolve-Url($url) { $wc = new-object Net.WebClient $urib = [UriBuilder] $url $urib.Scheme = "http" $urib.Path= "/Manager/ResolveUri" $wc.UploadString($urib.uri,$url) } function Get-TD($url) { $urib = [UriBuilder] $url $urib.Scheme = "http" $urib.Path= "/Manager" $wc = new-object Net.WebClient $wc.Headers.Add( "Content-Type" , 'application/soap+xml; charset=utf-8; action="urn:coral8.com:SOAPAction"' ) $soapBody = "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:soapenc='http:...


  • More than one way to do it, Part I - Powershell

    So my coworker , err boss :) seems to have started playing with Powershell, which is great. It looks like his first foray into PowerShell development is a commandlet for tibco ems topics . My initial feeling on this is that the benefits of commandlets syntax checking are not worth the tax of compiling and installing it. I would've used a native PowerShell approach. On the other hand, a full navigation provider... function Get-TibcoTopic([string]$topicName, [string]$url= "tcp://localhost:7222" , [string]$username= "admin" , [string]$password) { $null = [Reflection.Assembly]::LoadFrom( "C:\tibco\ems\clients\cs\TIBCO.EMS.dll" ) $null = [Reflection.Assembly]::LoadFrom( "C:\tibco\ems\clients\cs\TIBCO.EMS.ADMIN...


  • Interesting Finds: 2008.05.18

    Debug ASP.NET Tips: What to gather to troubleshoot - part 3a - Crash revisited Using Process Explorer without an Internet Connection .NET Fast LZW Compression Using Binary Tree Getting Image Metadata with C# Web Javascript Tutorial - Continuous Pagination 20 Useful Tools to Make Web Development More Efficient Mojax - a mobile Ajax application framework Other Request/Response Testing with Windows PowerShell What Determines High Quality Code? Writing code that you’re proud of Read More...


  • PowerShell: Threading Enhancements FTW!

    To build on the threading library I mentioned here , I've added some functionality to make it easier to communicate with the seperate thread. Still, keep in mind that PowerShell will only allow one pipeline to be executing in a runspace at any given time. So, these new functions can only be used while the thread is inactive. But, they provide power into setting up the thread to be run and communicating with the original runspace. The new functions are as follows: Get-ThreadVariable - Accesses available variables from within the thread. Set-ThreadVariable - Sets a variable for use within the thread. Invoke-ThreadExpression - Allows synchronous execution of a script block within the thread. I also updated the Join-Thread function to include...


Page 1 of 6 (56 items) 1 2 3 4 5 Next > ... Last »
Microsoft Communities