Bobdee
 Basic Member Posts:130

 |
| 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.
|
|
|
|
|
PoSherLife
 Basic Member Posts:364

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Bobdee
 Basic Member Posts:130

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Bobdee
 Basic Member Posts:130

 |
| 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.
|
|
|
|
|
Bobdee
 Basic Member Posts:130

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

 |
|
Bobdee
 Basic Member Posts:130

 |
|
Bobdee
 Basic Member Posts:130

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

 |
|
Bobdee
 Basic Member Posts:130

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Bobdee
 Basic Member Posts:130

 |
| 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. |
|
|
|
|
Bobdee
 Basic Member Posts:130

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Bobdee
 Basic Member Posts:130

 |
| 09 Jun 2010 02:39 AM |
|
2008 64x... |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Bobdee
 Basic Member Posts:130

 |
| 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.
|
|
|
|
|
Bobdee
 Basic Member Posts:130

 |
| 09 Jun 2010 07:05 AM |
|
I didn't work. |
|
|
|
|
Bobdee
 Basic Member Posts:130

 |
| 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. |
|
|
|
|
Bobdee
 Basic Member Posts:130

 |
| 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 Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
0ptikGhost
 Basic Member Posts:296

 |
| 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... |
|
|
|
|