Justin Marshall
unread,Apr 9, 2015, 5:54:27 PM4/9/15You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I have been building a server diff script for IIS and i've found that using the web-administration module is dramatically slower than WMI to get the same information. I built the WMI module first as i am working on a 2003 sunset project yet i found when i started into the IIS7 methods it was extremely slow.
Processing time -- IIS7: 348.988, IIS6: 10.309 (seconds)
The biggest time loss is in retrieving the properties for each directory under the webapp, this is taking ~5 seconds per 10 directories or 2 seconds each! WMI can do the entire website in 10 seconds.
. C:\scripts\PS\bits\Get-SelectPropertyArray.ps1
. C:\scripts\PS\bits\Get-FlagAsList.ps1
function Get-IIS7ConfigForPSPath
{
[CmdletBinding()]
param (
[string]$PSPath
)
$propsToSelect = @("Name","Path","PSPath")
<# Check the FlagValue datatype because when not configured it returns an object instead of an empty string! #>
$propsToSelect += Get-SelectPropertyArraySet "." "Handlers_AccessFlags" {
$flagValue = (get-webconfigurationProperty -filter /system.webServer/handlers -Name AccessPolicy -PSPath $PSPath)
if ($flagValue.GetType().Name -eq "ConfigurationAttribute")
{ "" } else {$flagValue}
}
<# Check the FlagValue datatype because when not configured it returns an object instead of an empty string! #>
$propsToSelect += Get-SelectPropertyArraySet "." "Access_sslFlags" {
$flagValue = (get-webconfigurationProperty -filter /system.webServer/security/access -Name sslFlags -PSPath $PSPath)
if ($flagValue.GetType().Name -eq "ConfigurationAttribute")
{ "" } else {$flagValue}
}
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_AppAllowClientDebug" {
(get-webconfigurationProperty -filter /system.webServer/asp -Name AppAllowClientDebug -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_AppAllowDebugging" {
(get-webconfigurationProperty -filter /system.webServer/asp -Name AppAllowDebugging -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_limits_bufferingLimit" {
(get-webconfigurationProperty -filter /system.webServer/asp/limits -Name bufferingLimit -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_EnableParentPaths " {
(get-webconfigurationProperty -filter /system.webServer/asp -Name EnableParentPaths -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_limits_queueTimeout" {
(get-webconfigurationProperty -filter /system.webServer/asp/limits -Name queueTimeout -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_limits_requestQueueMax" {
(get-webconfigurationProperty -filter /system.webServer/asp/limits -Name requestQueueMax -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "Asp_limits_scriptTimeout" {
(get-webconfigurationProperty -filter /system.webServer/asp/limits -Name scriptTimeout -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "security_auth_Anonymous" {
(get-webconfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -Name Enabled -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "security_auth_Basic" {
(get-webconfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name enabled -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "web_limits_ConnectionTimeout" {
(get-webconfigurationProperty -filter /system.applicationHost/webLimits -Name ConnectionTimeout -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "HttpCompression_DoDynamicCompression" {
(get-webconfigurationProperty -filter /system.webServer/httpCompression/scheme -Name DoDynamicCompression -PSPath $PSPath).Value }
$propsToSelect += Get-SelectPropertyArraySet "." "HttpCompression_DoStaticCompression" {
(get-webconfigurationProperty -filter /system.webServer/httpCompression/scheme -Name DoStaticCompression -PSPath $PSPath).Value }
# convert property array sets into selectable properties
$props = $propsToSelect | Get-SelectPropertyArray2
# retrieve the properties, no pipeline input is required as we are doing all the logic in the script blocks
$config = Get-Item $PSPath | select -Property $props
if ( !($config.Path) -or $config.Path -eq $null)
{
$config.Path = $PSPath
}
return $config
}
Get-IIS7ConfigForPSPath -PSPath ("IIS:Sites\{0}" -f $iis7Site.name)
This is the one that is killing me as i have to do this 160+ times per virtual directory:
Get-IIS7ConfigForPSPath -PSPath $iis7vwebfolderpath
by comparison here is my WMI request:
$start = [System.DateTime]::Now
$numanalyzed = 0
$iis6VWebDirConfig = @()
foreach ($vdir in $iis6VirDirConfig)
{
#retrieve the desired fields for the web directory
$iis6VWebDirConfig += Get-WmiObject -class IIsWebDirectorySetting -Namespace "root/MicrosoftIISv2" `
-Filter ("Name like '"+$vdir.Name+"%'") |
select -Property $props
$numAnalyzed++
$end = [System.DateTime]::Now
$timeSoFar = (NEW-TIMESPAN -Start $Start -End $End).TotalSeconds
$timeremaining = ($iis6VirDirConfig.Count - $numAnalyzed) * ($timeSoFar / $numanalyzed)
"Analyzed {0} so far... took {1} seconds, remaining time {2} seconds" -f $numanalyzed,$timeSoFar,$timeremaining | write-host
"Current Folder: {0}" -f $folder.FullName | Write-Host
}
"Web Directories Found: {0}" -f $iis6VWebDirConfig.Count | Write-Host
$end = [System.DateTime]::Now
"Processed web dirs: {0} took {1} seconds" -f $iis7VWebDirConfig.Count,(NEW-TIMESPAN -Start $Start -End $End).TotalSeconds | write-host | Write-Host
anyone know of a better way to get all those properties from IIS?