header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Remote IIS 7 management
Last Post 15 Jul 2010 01:13 PM by 0ptikGhost. 23 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
BobdeeUser is Offline
Basic Member
Basic Member
Posts:130
Avatar

--
07 Jun 2010 03:23 AM
    Hi,

    I'm trying to stop an applicaion pool in IIS 7 remotely using PS v2.

    I've installed the webadministration cmdlets, and can easily maintain IIS locally.  But, when I attempt to run anything remotely I recieve errors stating that the cmdlet I am running is not recognised - I have enabled PS Remoting, and can run other cmds on the machine using New-PSSession.

    Can anyone point me in the right direction as to what I am doing wrong please?  Here is the part of the script I am working on at the moment.

    [System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" )
    $Session = New-PSSession -ComputerName 'QPROVA02'
    Invoke-Command -Session $Session -ScriptBlock { import-module 'webAdministration'; Stop-WebAppPool 'manageUsers' }


    thanks in advance.

    Robbie.
    PoSherLifeUser is Offline
    Basic Member
    Basic Member
    Posts:364
    Avatar

    --
    07 Jun 2010 07:12 AM
    You're loading the dll locally, but expecting to call it remotely. You'll need to load the dll in the remote session.

    $Session = New-PSSession -ComputerName 'QPROVA02'

    $block = {
    [System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" )
    import-module 'webAdministration'
    Stop-WebAppPool 'manageUsers'
    }

    Invoke-Command -Session $Session -ScriptBlock $block
    When at first you don't succeed Step-Into

    http://theposherlife.blogspot.com
    http://www.jandctravels.com

    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    07 Jun 2010 07:29 AM
    You can remove the LoadFrom() call. The WebAdministration module loads all the necessary DLL's for you.

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 01:24 AM
    I tried both ideas, and got the same error.

    Basically saying the start-webapppool is not a valid cmdlet.
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    08 Jun 2010 03:06 AM
    Try interactively:

    Enter-PSSession QPROVA02
    import-module webAdministration
    Stop-WebApp[ PRESS TAB]

    The command is tab completed?


    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 04:49 AM
    ok tried that...  Getting the same error.

    Import-Module : The specified module 'webAdministration' was not loaded because
     no valid module file was found in any module directory.
        + CategoryInfo          : ResourceUnavailable: (webAdministration:String)
       [Import-Module], FileNotFoundException
        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
       ands.ImportModuleCommand

    Then (obviously)

    The term 'stop-webapppool' is not recognized as the name of a cmdlet, function,
     script file, or operable program. Check the spelling of the name, or if a path
     was included, verify that the path is correct and try again.
        + CategoryInfo          :
        + FullyQualifiedErrorId : CommandNotFoundException

    What I have also tried is running the same cmds from the box itself, which has produced the same result.  Would that make any difference?  I didn't think it would as PS would just open another session over the network??

    Perhaps re-installing the web admin cmdlets again??  I've ran out of knowledge / options now.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 04:59 AM
    But to answer your question...  No - Tabbing the cmd doesn't initialize the cmdlet.
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    08 Jun 2010 05:06 AM
    Do you get a result when you run the following inside the session:

    Get-Module WebAdministration -ListAvailable

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 05:09 AM
    No
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 05:09 AM
    PS C:\> get-module webadministration -listavailable
    PS C:\>
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    08 Jun 2010 05:16 AM
    Then the webadministration module doesn't exist on the target.

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 05:21 AM
    I can use the cmdlets locally on it no problem... Is there a posibility they are named something else?

    I am a little confused here as I can use the cmdlets - for example start / stop-webAppPool when I am on the server itself. It works perfectly.

    Do you think removing them, and re-installing might offer some relief?
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    08 Jun 2010 05:28 AM
    How do you load the module when you're working locally on the server? 'gmo web* -list' returns the module?

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 05:39 AM
    It's quite odd...

    ModuleType Name ExportedCommands
    ---------- ---- ----------------
    Manifest BitsTransfer {}
    Manifest PSDiagnostics {Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManCombined...


    PS C:\Users\da-rdixon> start-webapppool manageusers
    PS C:\Users\da-rdixon>

    does this mean that the module is not loading? If so how can I run the cmd - i checked it in IIS GUI, and the app pool was definately started when it was stopped.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    08 Jun 2010 05:41 AM
    I don't actually manually load the module, I open the powershell modules interface and that loads them for me.

    I also tried the power gui from quest software to see if I could load the libraries through it, and it works fine too. Unless I try remote connection, which is my objective.
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    09 Jun 2010 01:45 AM
    What's the OS type on the remote server?

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    09 Jun 2010 02:39 AM
    2008 64x...
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    09 Jun 2010 02:43 AM
    You need to install the IIS powershell provider:

    http://www.iis.net/download/PowerShell


    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    09 Jun 2010 06:44 AM
    I have this installed. I can run the cmdlets when I am on the server itself no problems at all.

    I guess trying a re-install might work.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    09 Jun 2010 07:05 AM
    I didn't work.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    10 Jun 2010 04:26 AM
    Does the webadministration module need to be installed on the local server?

    I mean, I only have it installed on the server I am connecting to then running the script against.
    BobdeeUser is Offline
    Basic Member
    Basic Member
    Posts:130
    Avatar

    --
    10 Jun 2010 05:55 AM
    FINALLY!!!
    $Session = New-PSSession -ComputerName QPROVA02
    Invoke-Command -Session $Session -ScriptBlock { Add-PSSnapin webadministration ; start-webapppool manageusers }

    Life is good!

    Thanks for the aid Shay - I honestly didn't have a clue how to do it, but you pointed me in the right direction!

    Rob :-)
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    10 Jun 2010 06:48 AM
    Awesome :)

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    0ptikGhostUser is Offline
    Basic Member
    Basic Member
    Posts:296
    Avatar

    --
    15 Jul 2010 01:13 PM
    Posted By bobdee1980 on 08 Jun 2010 04:49 AM

    Import-Module : The specified module 'webAdministration' was not loaded because
     no valid module file was found in any module directory.
        + CategoryInfo          : ResourceUnavailable: (webAdministration:String)
       [Import-Module], FileNotFoundException
        + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Comm
       ands.ImportModuleCommand

    This error should have told you that the WebAdministration module is not installed on the remote server. I assume you eventually came to this conclusion but I wanted to point this out explicitly here in case somebody else runs into this issue.

    EDIT: This should teach me to read all pages on a topic... The other posts already covered this...

    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer