Powershell Cheatsheet
One of the things that I have been getting use to is powershell, I'm not a server administrator. Or at least if I'm going to be one I prefer linux. Most of my server are and I'm going to have a update here once I get my lab setup. For now this is how I manage my job and correct the systems that have gone wild.
- http://www.anotherchris.net/misc/starting-and-stopping-all-iis-sites-in-powershell/
- http://stackoverflow.com/a/21674873/1265036
- https://social.technet.microsoft.com/Forums/windows/en-US/be3afe83-4a7e-48a0-b2e7-95fd081a7571/login-to-website-using-powershell?forum=winserverpowershell
- http://stackoverflow.com/a/25035181/1265036
- http://stackoverflow.com/questions/15528492/display-all-sites-and-bindings-in-powershell
- https://stackoverflow.com/questions/12789516/powershell-download-files-from-url-that-does-not-include-file-name-in-the-ur
- https://stackoverflow.com/questions/6204003/kill-a-process-by-looking-up-the-port-being-used-by-it-from-a-bat
- https://stackoverflow.com/questions/18438100/deploying-my-visual-studio-web-application-using-iis
Get-WebBinding | % {
$name = $_.ItemXPath -replace '(?:.*?)name=''([^'']*)(?:.*)', '$1'
New-Object psobject -Property @{
Name = $name
Binding = $_.bindinginformation.Split(":")[-1]
}
} | Group-Object -Property Name |
Format-Table Name, @{n="Bindings";e={$_.Group.Binding -join "`n"}} -Wrap
Import-Module webAdministration # Required for Powershell v2 or lower
$filepath = #your_output_filepath
$sites = get-website
foreach($site in $sites) {
$name = $site.name
$bindings = $site.bindings.collection.bindinginformation.split(":")
$ip = $bindings[0]
$port = $bindings[1]
$hostHeader = $bindings[2]
"$name,$hostHeader,$ip,$port" | out-host
"$name,$hostHeader,$ip,$port" | out-file $filePath -Append
}
Managing folders & files
Sometimes moving around files is an issue because of the thumbs.db file
Setup Subdomains
http://stackoverflow.com/questions/4069278/how-to-set-up-subdomains-on-iis-7
Fixed Memory
https://serverfault.com/questions/102387/how-to-free-used-memory-in-windows-server-2008-r2
More coming soon...