An Unrivaled Windows Hosting Experience
1-888-313-9421  | webteam@orcsweb.com
  1. FREE eBook: .NET Performance Testing and Optimization

    Paul Glavich and Chris Farrell have written a book on performance testing and optimization for .Net and it's available as a free eBook download from the Red Gate website. The price cannot be beat - FREE! You should go check it out.

     

    Tuesday, February 09 2010 by | 0 comment(s)
    Tagged as: , , , ,

  2. C# = or ==

    I learned my second key C# item just now ... Using = means an assignment. Using == means a comparison.

    So...

     Label1.Text == "Yes!"

    ... means DOES label1.text equal "Yes!"

    and...

     Label1.Text = "Yes!"

    ... means assign label1.text equal to "Yes!"

    It's very helpful to know these little things. :-)
     

    Wednesday, January 27 2010 by | 0 comment(s)
    Tagged as: , , ,

  3. PowerShell’ing on Windows Server: How to import certificates using PowerShell!

    Importing a certificate to a computer…you’d think the PowerShell method would be plastered all over the web, but oh no!  I had to figure most of this out all by my lonesome.  Okay, not *all* by my lonesome, but it felt that way.  There was one set of functions I found that worked as long as you use the x86 (aka 32-bit) version of PowerShell, but since I’m a 64-bit kind of guy I prefer my code to work in both the 32-bit and the 64-bit versions of PowerShell.

     

    For your reference, the 32-bit only method is here:

     

    http://blogs.msdn.com/daiken/archive/2007/01/12/windows-powershell-met-capicom.aspx

     

    This method does not work on Windows Server 2008 64-bit because the CAPICOM object does not have a 64-bit COM+ application.  Using this code in PowerShell 64-bit gives you lots and lots of nasty red on black text.  Which meant it was time to go back to the drawing board.

     

    In case you didn’t know, PowerShell has a drive for certificates.  Just type in “set-location cert:” (minus the “”) in PowerShell and you are now in your certificate store.  I blogged about this a bit in my MD5 certificate blog post a while back, so I won’t go into that much.  This was a good start, because it let me know what .NET class PowerShell uses for its certificates by looking at the “get-member” properties of a certificate.  Why is this important, you may be wondering?  Because PowerShell is just a scripting language built on top of the .NET framework.  Which means if you know what .NET class to manipulate you can do far more in PowerShell than just reading the cmdlet help files.   In this case I used the following command to get the .NET class.

    1. gci cert:\localmachine\root | gm   
     

    ...which translates to this using the long way...

     
    1. get-childitem cert:\LocalMachine\root | get-member   
     

    I used cert:\LocalMachine\root because I know there are always certificated there, so I will get the right class I need use.  And sure enough, at the top of the get-member output you get the .NET class of “System.Security.Cryptography.X509Certificates.X509Certificate2.”  With the .NET class in hand I did a quick MSDN search and started my research.

     

    http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.aspx

     

    I’ll spare you readers the boring trial and error stuff and skip straight to the results.  There is a way to import certificates, both X.509 (.cer) and .PFX and all other supported types.  All you need to do it use one of these two handy functions.

     
    1. function Import-PfxCertificate {    
    2.   
    3.    param([String]$certPath,[String]$certRootStore = “CurrentUser”,[String]$certStore = “My”,$pfxPass = $null)    
    4.    $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2    
    5.   
    6.    if ($pfxPass -eq $null) {$pfxPass = read-host "Enter the pfx password" -assecurestring}    
    7.   
    8.    $pfx.import($certPath,$pfxPass,"Exportable,PersistKeySet")    
    9.   
    10.    $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)    
    11.    $store.open("MaxAllowed")    
    12.    $store.add($pfx)    
    13.    $store.close()    
    14. }   
     

    Import-PfxCertificate should be used when importing a certificate that requires a password.  I didn’t go all crazy on the password security, but you can add that outside the function in your code pretty easily.  If I add some later on I’ll do some updates to the blog post.  To use the function you pass one to four parameters.

     

    $certPath = the location of the certificate file.  Required.

    $certRootStore = either “LocalMachine” or “CurrentUser”.  Default is CurrentUser, which is your personal user store.  LocalMachine is well … the computer’s certificate store.  IIS site certificates go here.

    $certStore = any number of items.  If you go to the cert: drive, then change the directory to either LocalMachine or CurrentUser and run “dir” you will see a list of all the cert stores.  My = Personal, root = Trusted Root Certificate Authorities, etc.  These “directory names”, or certificate stores, is what you enter for this variable.  Again, didn’t go crazy with the error correction in this function, but as long as you pass the right store all is well.

    $pfxPass = the password of the pfx, or other passwords protected certificate files.  If none is specified you get a prompt, which stores the pass as a securestring.  You *can* pass a plain text password, but I wouldn’t recommend it unless you know the script is secure.  You can also pass a secure string to the function, using whatever securestring storage method you prefer…or can find.

     

    Example:

     

    Import-PfxCertificate "C:\temp\testCert.pfx" "LocalMachine" "My"

     

    The second function is for certificates that do not require a password.

     
    1. function Import-509Certificate {    
    2.   
    3.    param([String]$certPath,[String]$certRootStore,[String]$certStore)    
    4.   
    5.    $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2    
    6.    $pfx.import($certPath)    
    7.   
    8.    $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore)   
    9.    $store.open("MaxAllowed")    
    10.    $store.add($pfx)    
    11.    $store.close()    
    12. }   
     

    The variables are the same as before, the function merely lacks password support.  Usage is identical to Import-PfxCertificate, just don’t pass it a password string or securestring.  I suppose you could, the function will just ignore it.

     

    That’s all there is to it.  If you’re still with me you may be wondering why I think this is so important.  Even working for a hosting company most certificates I handle don’t need this, even though you can use this to generate and complete certificate requests.  The reason I looked for this is because of code signing.  I can script the importation of the three required certificates for PowerShell code signing to a sever in seconds now.  Whether it was worth the effort is in the eye of the beholder, but I think it was.

    #James KehrGet-Member $OW | ?{$_.title –eq System Administrator”` –and $_.certification –match “MCITP 2008, MCSE 2000, MCDST, Network+, A+”}

    New-Variable –name company –value ‘ORCS Web, Inc.–description www.orcsweb.com | 1.888.313.9421’ 

    Thursday, August 06 2009 by | 0 comment(s)
    Tagged as: , ,

  4. Five years ago I had my head in the clouds...

    Five years ago I had my head in the clouds and wrote a short introductory article about highly-available and highly-scalable hosting.

     http://www.orcsweb.com/articles/web_cluster.aspx

    Yes, in February of 2004 I was trying to help people understand and appreciate the benefit of cloud hosting. I didn't have the marketing powerhouse of Microsoft or Google, nor was the term "cloud" being used in the industry, but the technology was available and at ORCS Web we had already been supporting clients of various sizes on cloud platforms with great success.

    I continue to be a huge fan of cloud hosting and believe it deserves consideration from anyone who takes their web application hosting seriously. Success on the platform takes a lot more than just throwing a few servers online though so clients should be looking for a host with years of experience and proven successes. There is also more to hosting than just the infrastructure. Strong technical support and excellence in customer service are also key to successful hosting solutions so clients should read reviews and check references before entering into a hosting relationship.

    We'd love to help your web solutions be successful so let us know if you have any questions or if there is anything we can do for you.

    Happy hosting!

    Brad

     

     

    Sunday, February 01 2009 by | 0 comment(s)
    Tagged as: , , , , , , ,

  5. Dividision Within a SQL Statement With Decimal Results

    I was surprised to find that this SQL statement does not return .36 as I had expected:

    select 36/100 as ShowPercent

    From some online searching I found a post which commented that a decimal result from a division operation would not display properly if both of the values were integers. I have no idea why, but that does seem to be true. The change I made to get the correct result was:

    select 36/cast(100 as float) as ShowPercent

    ~Brad

    Tuesday, December 23 2008 by | 1 comment(s)
    Tagged as: , , , ,

  6. Dedicated Cloud Solutions

    I've noticed that a few hosting companies are now advertising that they have "dedicated cloud" solutions. That's an interesting bit of marketing. A dedicated cloud, as I understand it (and confirmed by details on competitor sites) is basically a webfarm front-end with possibly a database cluster on the backend (though often the term "cloud" is targeted toward the front-end solution).

    Either these companies are new to the webfarm / cloud space, or they're just putting a marketing twist on existing services.

    At ORCS Web we have been hosting highly-available and highly-scalable webfarm solutions for clients for over ten years. Here's a short case-study about a webfarm solution we manage for Lake Quincy Media. We also host webfarm / cloud solutions for http://www.asp.net/, http://www.zagat.com/, http://aspalliance.com/, and many other clients.

    I guess I need to start getting comfrotable with using the term cloud now since it seems to be the new buzzword. Whether you call it a cloud, webfarm, server farm, or anything else - I'm all for HA/HS solutions and believe that anyone who relies heavily on their web site/application being online should go this route. It's the best way to avoid costly downtime that might otherwise occur with hardware failure or resource overload.

    Happy Hosting!

    ~Brad

     

    Tuesday, December 23 2008 by | 0 comment(s)
    Tagged as: , , , , , , , , ,