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.



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...

Popular posts from this blog

Aspetcore: NLog with Postgresql

Mongodb Cheatsheet

Installing Windows on Acer chromebook 15 cb3-532