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"
2

1 Answer 1

5

You didn't specify which version of IIS. If you are on 7.x, you can use the web administration module. Your script would resemble this:

$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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.