2010-07-14 4 views
2

Vous ne savez pas quel est le problème? J'utilise Powershell 2.0 sur Windows 7. Si ce même script fonctionnait sous Windows XP, est-ce que je manque quelque chose?Redémarrer le pool d'applications IIS6 - Erreur ADSI

$server = "server1-vm1.prod.ds.russell.com" 
$name = "Superduper_Reports" 
$iis = [ADSI]"IIS://$server/W3SVC/AppPools/$name" 
$iis.psbase.invoke("recycle") 

Erreur (qui Invoke semble correct pour moi?):

Exception calling "Invoke" with "2" argument(s): "Unknown error (0x80005000)" 
At line:3 char:19 
+ $iis.psbase.invoke <<<< ("recycle") 
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

Lorsque vient courir $iis variable i obtenir cette erreur:

The following exception occurred while retrieving member "PSComputerName": "Unknown error (0x80005000)" 
    + CategoryInfo   : NotSpecified: (:) [format-default], ExtendedTypeSystemException 
    + FullyQualifiedErrorId : CatchFromBaseGetMember,Microsoft.PowerShell.Commands.FormatDefaultCommand 

Roooarr! Je préfère utiliser ADSI sur WMI! De l'aide? :)

Répondre

1

Je pense que vous pouvez utiliser le module WebAdministration pour cette

Import-Module WebAdministration 
Get-Command -Module WebAdministration 
Get-ChildItem IIS: 

Vous trouverez un bon nombre de cmdlets pour administration IIS et un nouveau lecteur IIS:

Vous trouverez sur this Microsoft Web site quelques explications .

+0

Merci! Pourriez-vous corriger la faute de frappe dans votre extrait? ajoutez le d à Get-ChildItem IIS: –

0

Ce question a un script WMI qui a été déclaré pour fonctionner.

Sinon ADSI équivalent ressemblerait à quelque chose comme ça ...

http://geekswithblogs.net/Lance/archive/2010/12/16/powershell-ndash-recycle-all-iis-app-pools.aspx

function Recycle-AppPools { 

    param(
    [string] $server = "3bhs001", 
    [int] $mode = 1, # ManagedPipelineModes: 0 = integrated, 1 = classic 
    ) 

    $iis = [adsi]"IIS://$server/W3SVC/AppPools" 
    $iis.psbase.children | %{ 
     $pool = [adsi]($_.psbase.path); 
     if ($pool.AppPoolState -eq 2 -and $pool.ManagedPipelineMode -eq $mode) { 
      # AppPoolStates: 1 = starting, 2 = started, 3 = stopping, 4 = stopped   
      $pool.psbase.invoke("recycle") 
     } 
    } 

} 

Vous ne pouvez pas recycler un mais AppPool arrêté donc vous devez vérifier cela.

Questions connexes