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 | 5,628 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,133 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,157 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,035 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,507 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.


Posted in Hosting & IIS7, Windows Powershell | 4 Comments | 11,528 views | 11/12/2010 01:25

Detailed script about how to create website in IIS7 with Powershell.

1
2
3
4
5
6
7
Function Create-WebSite
{
Param ($LogDir, $Description, $Domain)
 
     $Domain = ($Domain.TrimStart("www")).TrimStart(".")
     New-Item IIS:\Sites\$Description -Bindings (@{Protocol="http";BindingInformation="*:80:$Domain"},@{Protocol="http";BindingInformation="*:80:www.$Domain"}) -PhysicalPath "$LogDir\http"
}

$LogDir is the path of FTP directory and $Description is the name of the website.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 2,309 views | 11/12/2010 01:22

One of my script about how to set ACL for FTP users.

1
2
3
4
5
6
7
8
9
10
11
12
Function Set-FTPACL
{
Param ($FTPUsername, $LogDir)
 
    $Account = New-Object System.Security.Principal.Ntaccount("$FTPUsername")
    $Sid = $Account.Translate([System.Security.Principal.SecurityIdentifier])
    $ACL = Get-Acl -Path "$LogDir"
    $Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow"
    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
    $ACL.SetAccessRule($AccessRule)
    $ACL | Set-Acl "$LogDir"
}

$LogDir is the path of FTP directory.