Install PowerShell and Powershell ISE on Windows Server

Windows Server 2003

For Windows server 2003, PowerShell V1 was released as KB ( hotfix). Download and install KB926139 – Windows PowerShell 1.0 English-Language Installation Package for Windows Server 2003

If you need PowerShell V2, make sure you have SP2 installed and then install Windows Management Framework from http://support.microsoft.com/kb/968929

Windows Server 2008

For Windows Server 2008 run the following command in an elevated Command Prompt.

servermanagercmd -install PowerShell

Windows Server 2008 R2

Windows Server 2008 R2 has PowerShell V2 built in and enabled by default, however, PowerShell ISE is not. It is installed on Windows 7 client OS, but an Optional Component on Windows Server 2008 R2. To Install PowerShell ISE on R2, run the following command in a Windows PowerShell Modules prompt

Add-WindowsFeature PowerShell-ISE

OR

  1. In Server Manager, start the Add Roles and Features wizard.
  2. On the Features page, select Windows PowerShell ISE.

Windows Server 2012

Windows Server 2012 has both PowerShell V3 built in and installed. PowerShell ISE needs to be added as it’s an optional Windows PowerShell feature, same as Windows Server 2008 R2.

Also checkout How to run PowerShell scripts to start your first PowerShell script.

TFS How to change the computer name or owner for a workspace

The owner and computer name of the workspace are not editable in Visual Studio 2010. However, you might need it when you renamed your machine or your account is renamed. To do this, open a Visual Studio Command Prompt (2010) from program files, and cd to your workspace, then run following

Change the computer name for a workspace

tf workspaces /updateComputerName:<OldComputerName> /collection:<CollectionURL>

You need replace <OldComputerName> to your actual old computer name and <CollectionURL> to your actual TFS collection URL.

Change the owner for a workspace

tf workspaces /updateUserName:<OldUserName> /collection:<CollectionURL>

HTTP Error 404.13 – Not Found Error When Upload Big File using WCF

On IIS 7.5, if you upload big file thru WCF service, you might get http 404.13 error from IIS server.

HTTP Error 404.13 – Not Found
The request filtering module is configured to deny a request that exceeds the request content length.

The solution is set a higher value for maxAllowedContentLength in web.config of application

<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>

Generate GUID in PERL

It’s very common for developer to generate a GUID in code to guarantee uniqueness. Here is the sample code to generate a GUID in Perl

my $guid = `uuidgen.exe`;
chomp $guid;

Uuuidgen.exe is a tool from DotNet Framework. You can append "-c" option to generate uppercase letters

Run uuidgen /? to see the detail usage of uuidgen.
Microsoft UUID Generator v1.01 Copyright (c) Microsoft Corporation. All rights reserved.

usage: uuidgen [-xisconvh?]
        x – Generate sequential (V1) UUIDs
        i – Output UUID in an IDL interface template
        s – Output UUID as an initialized C struct
        c – Output UUID in upper case
        o<filename> – redirect output to a file, specified immediately after o
        n<number> – Number of UUIDs to generate, specified immediately after n
        v – display version information about uuidgen
        h,? – Display command option summary

IIS 7.5 Error The temp directory in chart handler configuration is not accessible

If you build a web application with Chart control for ASP.NET 4.0 and deploy the site to web server.  You might get following error on the live site:

The temp directory in chart handler configuration is not accessible

To resolve this, first go to web.config and find the ChartImage directory in appsettings.

<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>

The go to the temp chart image directory and grant read and write permission to IIS working process account in share properties – security tab. Note that the account runs IIS working process is different between IIS 7 and IIS 7.5

  • On Windows Server 2008 has IIS7, grant Read and Write permission to Network Service
  • On Windows server 2008 R2 has IIS 7.5, grant Read and Write permission to AppPool\<PoolName>. Replace <PoolName> to the actual machine pool your site is running on, for example, if your site is running on pool named ASP.NET v4.0, then the account you need grant permission would be IIS AppPool\ASP.NET v4.0, you can refer this step by step instructions for detail