search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Hosting & IIS7, Windows Powershell | No Comment | 3,468 views | 16/12/2010 21:57

Simple function to just start and stop a website with Powershell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Function Change-IISStatus
{
Param ($Description, $Status)
 
    If ($Status -eq "0")
    {
        Stop-Website "$Description"
	}
 
    If ($Status -eq "1")
    {    
        Start-Website "$Description"
    }
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 4,348 views | 16/12/2010 21:55

Powershell function to setting connection limits for websites in IIS7.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Function Set-ConnectionLimits
{
Param ($Description, $MaxBandwidth, $MaxConnection)
 
    If ($MaxBandwidth -ne $Null)
    {
        Set-ItemProperty IIS:\Sites\$Description -Name Limits.MaxBandwidth -Value "$MaxBandwidth"
	}
 
    If ($MaxConnection -ne $Null)
    {    
        Set-ItemProperty IIS:\Sites\$Description -Name Limits.MaxConnections -Value "$MaxConnection"
    }
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 5,624 views | 16/12/2010 21:52

Powershell function to assign application pool to website in IIS7.

Function Set-AppPool
{
Param ($Description, $AppPool)
 
	Set-ItemProperty IIS:\Sites\$Description -Name ApplicationPool -Value "$AppPool"
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | 1 Comment | 7,123 views | 16/12/2010 21:49

Powershell function to create a new application pool in IIS7.

1
2
3
4
5
6
7
8
9
10
11
Function Create-AppPool
{
Param ($AppPool, $Username, $Password)
 
    New-Item IIS:\AppPools\$AppPool
    $NewPool = Get-Item IIS:\AppPools\$AppPool
    $NewPool.ProcessModel.Username = "$Username"
    $NewPool.ProcessModel.Password = "$Password"
    $NewPool.ProcessModel.IdentityType = 3
    $NewPool | Set-Item
}

You can set IdentityType for Network Service. Please check Technet for IdentityTypes.


Posted in Hosting & IIS7, Windows Powershell | 1 Comment | 9,155 views | 16/12/2010 21:45

Powershell function to modify Default Document configuration in IIS7.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Function Modify-DefaultDoc
{
Param ($Description, $DefaultDocName, $Action)
 
    If ($Action -eq "Add")
    {
        Add-WebConfiguration //DefaultDocument/Files -AtIndex 0 -Value @{Value="$DefaultDocName"} -PSPath IIS:\ -Location $Description 
    }
 
    If ($Action -eq "Remove")
    {
        Clear-WebConfiguration //DefaultDocument/Files -PSPath IIS:\ -Location $Description
    }
}

If you want to modify list, just change -AtIndex position.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 3,034 views | 11/12/2010 01:31

Simple script to modify IIS7 FTP Quota with Powershell.

1
2
3
4
5
6
Function Modify-FTPQuota
{
Param ($LogDir, $FTPQuota)
 
    DirQuota Quota Modify /Path:"$LogDir" /Limit:$FTPQuota
}

DirQuota command comes with File Services feature in Windows Server 2008 to limit directories.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 15,502 views | 11/12/2010 01:28

Detailed script about how to create IIS7 ftp site with Powershell.

1
2
3
4
5
6
7
8
9
10
Function Create-FTPSite
{
Param ($FTPUsername, $LogDir, $FTPQuota, $FTPUserDir)
 
        $FTPUserPath = ($FTPUsername.Split("\")[1])
        New-Item IIS:\Sites\".Default FTP Site"\$FTPUserDir\$FTPUserPath -Type VirtualDirectory -PhysicalPath "$LogDir"
        Add-WebConfiguration -Filter /System.FtpServer/Security/Authorization -Value (@{AccessType="Allow"; Users="$FTPUserPath"; Permissions="Read, Write"}) -PSPath IIS: -Location ".Default FTP Site/$FTPUserDir/$FTPUserPath"
        Clear-WebConfiguration -Filter /System.FtpServer/Security/Authorization -PSPath IIS: -Location ".Default FTP Site/$FTPUserDir"
        DirQuota Quota Add /Path:"$LogDir" /Limit:$FTPQuota
}

DirQuota command comes with File Services feature in Windows Server 2008 to limit directories.