« Previous Next »

Thread: creating new iis site with powershell. strange behaviour

Last post 10-29-2009 2:56 PM by ish13. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 10-29-2009, 8:05 AM

    • ish13
    • Not Ranked
    • Joined on 10-29-2009, 7:58 AM
    • Posts 2

    creating new iis site with powershell. strange behaviour

    hello,

     i'm writing script in powershell 2 for site creation . found strange behavious in the following code

    # Start-WebCommitDelay
       
       New-WebAppPool $domain
     
       New-Website -Name $domain -HostHeader $domain -IPAddress $ipaddr -PhysicalPath $domainroot -ApplicationPool $domain
      
      
      
       New-WebFtpSite -Name $user -HostHeader ($user+".vserver.ru" ) -IPAddress $ipaddr -PhysicalPath $userroot -Port 21
     
     #  Stop-WebCommitDelay

    if start and stop webcommitdelay commented , then this code works as expected , but if i uncomment them, then web site and ftp site builds incorrect. at least they do not have physical pass assigned .

     there is no information in help for start/stop web commit delay but i expected that they act like begin transaction and commit transaction

    any ideas why they broke sites creation ( or point me where i may read about this ) .

    also. second question . if using WebAdministration snaping for powershell , is there is any commit method .. i am trying to put logfiles to different directories by script ,

    like this

    PS IIS:\sites> $log = (get-item v127 | Select-Object log* )

    PS IIS:\sites> $log.logFile.directory="C:\inetpub\wwwroot\v127\logs"

    in powershell i see that changes accepted

    PS IIS:\sites> $log.logFile


    logExtFileFlags      : Date,Time,ClientIP,UserName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent,By
                           tesRecv,TimeTaken,ServerPort,UserAgent,Referer,HttpSubStatus
    customLogPluginClsid :
    logFormat            : W3C
    directory            : C:\inetpub\wwwroot\v127\logs
    period               : Daily
    truncateSize         : 20971520
    localTimeRollover    : False
    enabled              : True
    Attributes           : {logExtFileFlags, customLogPluginClsid, logFormat, directory...}
    ChildElements        : {}
    ElementTagName       : logFile
    Methods              :
    Schema               : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

    but in iis manager log file still points to different place .

    so i assume there may be some commit method to update configuration .

    tia

    ish

  • 10-29-2009, 2:56 PM In reply to

    • ish13
    • Not Ranked
    • Joined on 10-29-2009, 7:58 AM
    • Posts 2

    Re: creating new iis site with powershell. strange behaviour

    switch from snapin to assembly .. it seems to me there is some bug or i am doing something wrong.. i'am doing the same for www and ftp site .. for www site log directory changes, for ftp - not

     below is sample code

    v130 - is the name for ftp site

    www.v130.ru - is the name of www site

    the commands and results below

    in powershell it shows that all directories changed

    but iis manager shows that WWW log file directory changed and ftp - not

    any idea why ?

    tia

    ish

    [DBG]: PS C:\scripts>>> [Reflection.Assembly]::LoadFrom("C:\Windows\system32\inetsrv\Microsoft.Web.Administration.dll")

    GAC    Version        Location                                                                                                                                            
    ---    -------        --------                                                                                                                                            
    True   v2.0.50727     C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Administration\7.0.0.0__31bf3856ad364e35\Microsoft.Web.Administration.dll                                

     

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $i=New-Object microsoft.web.administration.servermanager

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $l=$i.sites["v130"].Logfile

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $l1=$i.sites["www.v130.ru"].Logfile

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $l.Directory="c:\inetpub\wwwroot\v130\logs"

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $l1.Directory="c:\inetpub\wwwroot\v130\logs"

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $i.CommitChanges()

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $i=New-Object microsoft.web.administration.servermanager

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $i.sites["www.v130.ru"].logfile.directory
    c:\inetpub\wwwroot\v130\logs

    ________________________________________________________________________________________________________________________________________________________________________
    [DBG]: PS C:\scripts>>> $i.sites["v130"].logfile.directory
    c:\inetpub\wwwroot\v130\logs

Page 1 of 1 (2 items)
Microsoft Communities