2

I am trying to write a simple script that lets you remotely add an app pool, site, and app to IIS using powershell.

I figured out how to do this using APPCMD with a .bat on the local machine, but I need to do this remotely.

My bat file works and contains:

%systemroot%\system32\inetsrv\APPCMD add apppool /name:"WCF Integrated 4.0" /managedRuntimeVersion:"v4.0" /managedPipelineMode:Integrated /processModel.identityType:"NetworkService" /enable32BitAppOnWin64:True

%systemroot%\system32\inetsrv\APPCMD add site /name:"WCF Site" /bindings:"http/*:88:" /physicalPath:"D:\wcf"

%systemroot%\system32\inetsrv\APPCMD add app /site.name:"WCF Site" /path:/Service/Host /physicalPath:"D:\wcf\Service"

%systemroot%\system32\inetsrv\APPCMD set app /app.name:"WCF Site/Service/Host" /applicationPool:"WCF Integrated 4.0"
4

1 回答 1

5

您没有指定哪个版本的 IIS。如果您使用的是 7.x,则可以使用 Web管理模块。您的脚本将类似于以下内容:

$Session = New-PSSession -ComputerName '<ComputerName>'

    $block = { 
        import-module 'webAdministration' 

            # Call IIS cmdlets here for adding app pools, creating web site and so on
    } 

Invoke-Command -Session $Session -ScriptBlock $block
于 2012-04-24T20:04:12.370 回答