« Previous Next »

Thread: How can i use Script PowerShell with IIS7 PowerShell Snap-In

Last post 07-17-2009 4:16 PM by Marcio Morales. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 07-06-2009, 1:23 PM

    How can i use Script PowerShell with IIS7 PowerShell Snap-In

    Hey,

    I have a problem today, i need to create some sites with script powershell in IIS7, my script:

    New-Item D:\data\sites\NOMEDOSITE -type Directory

    New-Item IIS:\AppPools\NOMEDOSITE

    New-Item IIS:\Sites\NOMEDOSITE -physicalPath D:\data\sites\NOMEDOSITE -binding @{protocol="http";bindingInformation=":80:www.nomedosite.com.br"}

    Set-ItemProperty IIS:\Sites\NOMEDOSITE -name applicationPool -value NOMEDOSITE



    But when my script runs, the path IIS:\ don´t exist, how can i create this path in my script?

    ""This command line only work if i open the PowerShell Snap-In and write line by line. (no script) ""

  • 07-06-2009, 3:41 PM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

     did you try doing a "cd" into iis:\ ??

    Regards,
    MA Khan
    http://www.iisworkstation.com

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 07-07-2009, 9:00 AM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

     This is the problem, the IIS:\ is just mapped when you´re running the IIS 7 PowerShell Snap-In. When you´re running the normal PowerShell this IIS:\ isnt´s mapped and i don´t know where is the path that PowerShell Snap-In create for IIS:\

  • 07-08-2009, 3:08 PM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

     When you are running normal powershell you will 1st need to load the IIS snap-in module and then you can run the IIS cmd lets...

    more info at http://learn.iis.net/page.aspx/429/installing-the-iis-70-powershell-snap-in/

    Regards,
    MA Khan
    http://www.iisworkstation.com

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 07-14-2009, 2:36 PM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

    I have been attempting this same thing, and while writing a response to say that i couldnt get it to work, i got it to work..

     I had been trying to call the script from the command line, rather than the powershell prompt. When i do it from the powershell prompt it works.

     

    edit: i take that back.. calling the script directly from Powershell doesnt work. I'm not 100% certain what to call the prompt that i got it working from. I have the line from your above link in my code at the beginning (the bit on that page that is realted to manual registration). When i run my script from powershell or command prompt, that line in the code makes it open another prompt window, which i guess is the IIS powershell, and that is where i have gotten my script to work from.

     

  • 07-16-2009, 10:12 AM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

    So i found a way to successfully call an IIS ps script from command line.. but its long enough that i wouldn't really want to do it outside of a batch file.

     i looked at the properties of my shortcut to the IIS PS console from my start menu.

    Here's what i have in my batch file:

    powershell.exe -psconsolefile "C:\Program Files\IIS\PowerShellSnapin\IIsConsole.psc1" -NoExit -command  "c:\createsite.ps1"

    and of course the first path is the location of your powershell snapin, and the second path is to the script that im calling.

  • 07-17-2009, 4:16 PM In reply to

    Re: How can i use Script PowerShell with IIS7 PowerShell Snap-In

     Thanks... this line save my life:

     

     powershell.exe -psconsolefile "C:\Program Files\IIS\PowerShellSnapin\IIsConsole.psc1" -NoExit -command  "c:\createsite.ps1"

Page 1 of 1 (7 items)
Microsoft Communities