El TecnoBaúl de Kiquenet

Kiquenet boring stories

Posts Tagged ‘IIS’

Web Administration (IIS) , AppPools, WebSites using PowerShell

Posted by kiquenet en 6 agosto 2014

Trabajando con Powershell (Powershell Remoting) y AppPools – WebSites

Enter-PSSession –Computername SERVER-Credential SERVER\instalador

      (Nota:en este punto os pedirá la contraseña correspondiente al usuario)

Import-Module WebAdministration

Get-ChildItem IIS:\AppPools

Get-ChildItem IIS:\AppPools | ? {$_.state -eq "Started" -and $_.name –eq "myAppPool"}

Get-ChildItem -Path IIS:\Sites

Get-ChildItem -Path IIS:\Sites | ? {$_.state -eq "Started"}

Get-ChildItem -Path "IIS:\Sites\Default Web Site"

Get-ChildItem -Path "IIS:\Sites\Default Web Site" | ? {$_.name -eq "MyWebsite"}

Exit-PSSession

References:

http://technet.microsoft.com/es-es/library/ee909471(v=ws.10).aspx
http://www.iis.net/learn/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools
http://stackoverflow.com/questions/6616320/stop-default-web-site-by-powershell

Anuncios

Posted in PowerShell, Scripts | Etiquetado: , , | Leave a Comment »

Logs de IIS

Posted by kiquenet en 27 enero 2014

Ruta por defecto:

c:\inetpub\logs\LogFiles


Nota:

Otherwise, check under IIS Manager, select the computer on the left pane, and in the middle pane, go under "Logging" in the IIS area. There you will se the default location for all sites (this is however overridable on all sites)


También pueden encontrarse en siguientes rutas: C:\Windows\system32\LogFiles\W3SVC1

En esta ruta un log que contiene sólo los errores:

C:\Windows\System32\LogFiles\HTTPERR

Comprobar que esté activo:

Programs and Features

then click on

Turn Windows features on or off

on the left side then select

Internet Information Services\World Wide Web Services\Health and Diagnostics\HTTP Logging

Una referencia interesante, y que trata de la configuración de logs en IIS (sección <logFile> de settings)

http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults/logfile

Referencias:

http://stackoverflow.com/questions/6426375/where-can-i-find-the-iis-logs

http://techslate.net/es/cas-server-and-using-and-troubleshooting-iis-log-files/

http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults/logfile

Posted in IIS, Trucos | Etiquetado: , | Leave a Comment »

AppPools e IIS con Powershell

Posted by kiquenet en 24 enero 2014

Trabajando con Powershell y AppPools, para crear un Application Pool en:

Windows Server 2012 R2 con versión IIS 8.5

Windows Server 2008 R2 con versión IIS 7.5

Powershell 4.0

Algunos datos previos como la versión de Powershell:

$PSVersionTable.PSVersion.ToString()

Get-PSVersion

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" | Select -ExpandProperty PowerShellVersion

Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine" | Select -ExpandProperty PowerShellVersion

Y la versión de IIS:

Get-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp\  | select setupstring,versionstring
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters | select MajorVersion,MinorVersion,PSPath

Versión de Microsoft.Web.Administration:

$IISAssembly = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$IISVersion = $IISAssembly.GetName().Version
$IISVersionString = [string]::Format("{0}.{1}.{2}.{3}", $IISVersion.Major, $IISVersion.Minor, $IISVersion.Build, $IISVersion.Revision)
$IISVersionString

Algunas anotaciones a tener en cuenta respecto a la sintaxis: 

   Set-Location IIS:\AppPools
   $appPool = New-Item IIS:\AppPools\$name 
   $appPool.processModel.identityType = $processModelIdentityType
   $appPool.managedRuntimeVersion = $managedRuntimeVersion
   $appPool.managedPipelineMode = ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::$managedPipelineMode)
   $appPool | set-item

Otra forma podría ser utilizar Set-ItemProperty:

       Set-ItemProperty IIS:\AppPools\$AppPoolNameTest ProcessModel.IdentityType $processModelIdentityType
    Set-ItemProperty IIS:\AppPools\$name managedRuntimeVersion $managedRuntimeVersion
    Set-ItemProperty IIS:\AppPools\$name managedPipelineMode ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::$managedPipelineMode)
    Set-ItemProperty IIS:\AppPools\$name enable32BitAppOnWin64 true

    Get-ItemProperty IIS:\AppPools\$AppPoolNameTest managedRuntimeVersion
    Get-ItemProperty IIS:\AppPools\$AppPoolNameTest managedPipelineMode
    Get-ItemProperty IIS:\AppPools\$AppPoolNameTest ProcessModel.IdentityType

O utilizarse el comando AppCmd.exe:

system32\inetsrv\appcmd.exe set AppPool $AppPoolName -processModel.identityType:ApplicationPoolIdentity

En Windows Server 2012 – IIS 8.5 funcionó así también, en cambio no aplicaba cambios en Windows Server 2008 – IIS 7.5:

$appPool | set-ItemProperty -Name "managedRuntimeVersion" -Value $managedRuntimeVersion
$appPool | Set-ItemProperty -Name "managedPipelineMode" -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::$managedPipelineMode)
$appPool | set-ItemProperty -Name "managedPipelineMode" -Value $managedPipelineMode

Además,

set-ItemProperty -Name "managedRuntimeVersion" -Value $managedRuntimeVersion

producía un error de casting a int (Set-ItemProperty : [Microsoft.Web.Administration.ManagedPipelineMode]::Integrated is not a valid value for Int32).

De la siguiente manera se consigue solucionar:

Set-ItemProperty -Name "managedPipelineMode" -Value ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::$managedPipelineMode)

Si aparece el siguiente error indica que existe un Sitio Web con el mismo puerto:

start-webitem "Cannot create a file when that file already exists"

Útil además el manejo de versiones con PS:

$PSVersionTable.BuildVersion -ge [Version]"6.3.9421.0"

Una estupenda referencia: http://blogs.iis.net/jeonghwan/archive/2008/07/30/iis-powershell-user-guide-comparing-representative-iis-ui-tasks.aspx

Referencias:

https://gist.github.com/rasmuskl/1482665

https://gist.github.com/jstangroome/882528

http://learn.iis.net/page.aspx/434/powershell-snap-in-making-simple-configuration-changes-to-web-sites-and-application-pools/
http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel

http://www.iis.net/configreference/system.applicationhost/applicationpools

http://www.iis.net/learn/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools
http://blog.analysisuk.com/post/Configuring-IIS-7-Bindings-with-IIS-PowerShell-Provider.aspx
http://www.iisonthe.net/2012/07/25/changing-application-pool-identities-in-iis-78-using-powershell/
http://stackoverflow.com/questions/4229082/powershell-how-do-i-set-the-net-framework-version-when-using-new-webapppool
http://stackoverflow.com/questions/9282063/powershell-error-when-trying-to-use-set-itemproperty-with-defaultapppool

http://stackoverflow.com/questions/7988306/how-to-use-an-enum-type-in-powershell-when-configuring-iis-using-the-powershell

http://www.powershellmagazine.com/2014/01/03/pstip-validating-version-numbers-without-regex/

http://stackoverflow.com/questions/435050/how-to-determine-installed-iis-version
http://stackoverflow.com/questions/16784587/finding-version-of-iis-using-powershell

Posted in PowerShell, Scripts | Etiquetado: , , , , , , | Leave a Comment »

Recycling Application Pools in IIS 6.0

Posted by kiquenet en 6 mayo 2010

A quick tip for those of us fond of iisreset. Restarting IIS takes quite a while. Sometimes 15-20 seconds, when my w3wp.exe processes are particularly unruly. In many cases, though, a full iisreset is unnecessary. Since IIS 6.0 expanded its process isolation model to include Application Pools, the simplest way is to simply recycle the application pool – takes only a second, and usually does the trick.

We can do this in .NET with very little effort:

using(DirectoryEntry appPool = new DirectoryEntry(string.Format("IIS://{0}/w3svc/apppools/{1}", host, poolname)))
{
   appPool.Invoke("Recycle");
}

Or, if we want to use this in automation scripts or post-build events, we can wrap this in a console application.

Fuente:
http://weblogs.asp.net/avnerk/archive/2005/10/09/427075.aspx

Posted in .NET, ASP.NET, Scripts | Etiquetado: , | Leave a Comment »