Edit enableSessionState with PowerShell   

Tags:
Technorati Tags:

Instead of going to the web.config file you can use this little script to change your enableSessionState.

 

function Set-enableSessionState{
    param([string]$path = $(read-host "Please enter a web.config file to read"),
          [string]$value = $(read-host "Set Session State : 'true' or 'false'"))    
    
    $date = (Get-Date).tostring("mm_dd_yyyy-hh_mm_s");
    $backup = $path + "_$date";
    $xml = [xml](Get-Content $path);
 
 
    $xml.Save($backup);
    $root = $xml.get_documentElement();
    $sysweb = $root["system.web"];
    $sysweb.pages.SetAttribute("enableSessionState",$value);
    
    $xml.Save($path);    
}

 

Use:

Set-enableSessionState "C:\inetpub\wwwroot\wss\VirtualDirectories\91\web.config" "true"
 
Posted by  Gilissen Timmy  on  2/15/2012
0  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:        
 

Links to this post

Comments

Name *:
URL:
Email:
Comments:


CAPTCHA Image Validation