Import-Module WebAdministration | |
if(!$web8Files) | |
{ | |
$logfile = "$PSScriptRoot\Sites_$(get-date -format `"yyyyMMdd_hhmmsstt`").log" | |
} | |
#this is our logging function, it must appear above the code where you are trying to use it. | |
#note there is a technique to get around needing this at the top, read the blog post to find out more... | |
function log($message, $color) | |
{ | |
#$now = Get-Date -Format "MM-dd-yyyy_HH-mm-ss" | |
if ($color -eq $null) {$color = "white"} | |
write-host $message -foregroundcolor $color | |
$message = "$now $message" | |
Add-content $logfile -value $message | |
} | |
#list all sites, applications and appPools | |
dir IIS:\Sites | ForEach-Object { | |
# web site name | |
#log $_.Name $_.physicalpath | |
log ($_.Name + "," + $_.physicalpath) | |
# site's app pool | |
#$_.applicationPool | |
# any web applications in the site + their app pools | |
#Get-WebApplication -Site $_.Name | select applicationPool,physicalpath | Export-Csv -Path "D:\$_.Name.csv" | |
} # | Export-Csv -Path "D:\SitesToUpgrade.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment