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,913 views | 16/12/2010 22:16

Powershell function to set ReadOnly FTP in IIS7.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Function Set-ReadOnlyFTP
{
Param ($FTPUsername, $ACLRule, $Path)
 
    If ($ACLRule -eq "ReadOnly")
    {
	    $Account = New-Object System.Security.Principal.NtAccount("$FTPUsername")
	    $ACL = Get-Acl -Path "$Path"
	    $Permission = "$Account","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow"
	    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
	    $ACL.SetAccessRule($AccessRule)
            $ACL | Set-Acl "$Path"
    }
 
    If ($ACLRule -eq "Modify")
    {
	    $Account = New-Object System.Security.Principal.NtAccount("$FTPUsername")
	    $ACL = Get-Acl -Path "$Path"
	    $Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow"
	    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
	    $ACL.SetAccessRule($AccessRule)
            $ACL | Set-Acl "$Path"
    }
}

I won’t explain arguments because they are clear to understand.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 3,811 views | 16/12/2010 22:13

Advanced Directory ACL Powershell function for IIS7.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Function Set-DirACL
{
Param ($IUSRName, $Username, $Password, $ListRule, $Path, $ACLRule, $Description, $Directory)
 
    If ((Test-Path -Path $Path) -ne $True) 
    { 
        New-Item $Path -Type Directory
    }
 
    If ($ACLRule -eq "ReadAndExecute")
    {
	    $Account = New-Object System.Security.Principal.NtAccount("$IUSRName")
	    $ACL = Get-Acl -Path "$Path"
	    $Permission = "$Account","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow"
	    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
	    $ACL.SetAccessRule($AccessRule)
            $ACL | Set-Acl "$Path"
    }
 
    If ($ACLRule -eq "Modify")
    {
	    $Account = New-Object System.Security.Principal.NtAccount("$IUSRName")
	    $ACL = Get-Acl -Path "$Path"
	    $Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow"
	    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
	    $ACL.SetAccessRule($AccessRule)
            $ACL | Set-Acl "$Path"
    }
 
    If ($ListRule -eq "ListFolders")
    {
           Set-WebConfigurationProperty System.WebServer/DirectoryBrowse IIS:\Sites\$Description\$Directory -Name Enabled -Value True
    }
 
    If ($ListRule -eq "NotListFolders")
    {
           Set-WebConfigurationProperty System.WebServer/DirectoryBrowse IIS:\Sites\$Description\$Directory -Name Enabled -Value False
    }
}

I won’t explain arguments because they are clear to understand.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 4,483 views | 16/12/2010 22:07

Powershell function to removing bindings from websites in IIS7.

1
2
3
4
5
6
Function Remove-Binding
{
Param ($Description, $Binding)
 
	Remove-WebBinding -Name $Description -BindingInformation *:80:$Binding
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 5,454 views | 16/12/2010 22:05

Simple Powershell function to add new binding to IIS7 Websites.

1
2
3
4
5
6
Function Add-Binding
{
Param ($Description, $Binding)
 
	New-ItemProperty IIS:\Sites\$Description -Name Bindings -Value @{Protocol="http";BindingInformation="*:80:$Binding"}
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | 1 Comment | 5,410 views | 16/12/2010 22:00

Powershell function to setting basic authentication for websites in IIS7.

1
2
3
4
5
6
7
Function Set-UserPermissions
{
Param ($Description, $Username, $Password)
 
	Set-ItemProperty IIS:\Sites\$Description -Name Username -Value "$Username"
	Set-ItemProperty IIS:\Sites\$Description -Name Password -Value "$Password"
}

Description is the name of website in IIS7.


Posted in Hosting & IIS7, Windows Powershell | No Comment | 3,458 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,080 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.