Thursday, September 30, 2010

Install IIS and other IIS stuff on Server or a Desktop

I searched around, and didn't find anyone who had a way to install IIS from POSH. And if they got close, they didn't say that it didnt work on a server, or a desktop depending on the script. So here is one that will work on both, depending on what the user says they have:
#########################################################
#
# Script to install IIS.
#
# Created Sept 20, 2010
# Bryan Loveless 
#
#
# Requires Powershell 2.0
#
# Change your Execution policy to RemoteSigned if running locally
# by: Set-executionpolicy -executionpolicy RemoteSigned
#
#Prereqs: 
#
########################################################


$whorunsthis = Read-host "Is this a (S)erver or your (L)ocal_Developer box? (S/L)"

if ($whorunsthis -eq "S" )
    {   
 #get-windowsfeature will get list of Windows Component Intalled on SERVER

 Import-Module servermanager

 add-windowsfeature Application-Server
 add-windowsfeature AS-NET-Framework
 add-windowsfeature AS-Web-Support 
 add-windowsfeature AS-WAS-Support
 add-windowsfeature AS-HTTP-Activation  
 add-windowsfeature File-Services
 add-windowsfeature FS-FileServer
 add-windowsfeature Web-Server
 add-windowsfeature Web-WebServer
 add-windowsfeature Web-Common-Http
 add-windowsfeature Web-Static-Content
 add-windowsfeature Web-Default-Doc
 add-windowsfeature Web-Dir-Browsing
 add-windowsfeature Web-Http-Errors
 add-windowsfeature Web-Http-Redirect
 add-windowsfeature Web-App-Dev
 add-windowsfeature Web-Asp-Net
 add-windowsfeature Web-Net-Ext
 add-windowsfeature Web-ISAPI-Ext
 add-windowsfeature Web-ISAPI-Filter
 add-windowsfeature Web-Health
 add-windowsfeature Web-Http-Logging
 add-windowsfeature Web-Log-Libraries
 add-windowsfeature Web-Request-Monitor
 add-windowsfeature Web-Http-Tracing
 add-windowsfeature Web-Security
 add-windowsfeature Web-Basic-Auth
 add-windowsfeature Web-Windows-Auth
 add-windowsfeature Web-Digest-Auth
 add-windowsfeature Web-Client-Auth
 add-windowsfeature Web-Cert-Auth
 add-windowsfeature Web-Url-Auth
 add-windowsfeature Web-Filtering
 add-windowsfeature Web-IP-Security
 add-windowsfeature Web-Performance
 add-windowsfeature Web-Stat-Compression
 add-windowsfeature Web-Dyn-Compression
 add-windowsfeature Web-Mgmt-Tools
 add-windowsfeature Web-Mgmt-Console
 add-windowsfeature Web-Scripting-Tools
 add-windowsfeature Web-Mgmt-Service
 add-windowsfeature NET-Framework
 add-windowsfeature NET-Framework-Core
 add-windowsfeature NET-Win-CFAC
 add-windowsfeature NET-HTTP-Activation
 add-windowsfeature Multipath-IO
 add-windowsfeature RSAT
 add-windowsfeature RSAT-Role-Tools
 add-windowsfeature RSAT-Web-Server       
 add-windowsfeature SNMP-Services
 add-windowsfeature SNMP-Service
 add-windowsfeature SNMP-WMI-Provider
 add-windowsfeature Windows-Internal-DB
 add-windowsfeature PowerShell-ISE
 add-windowsfeature WAS
 add-windowsfeature WAS-Process-Model
 add-windowsfeature WAS-NET-Environment
 add-windowsfeature WAS-Config-APIs
 add-windowsfeature WSRM

}

elseif ($whorunsthis -eq "L")
    { 

 #oclist will give a list of what is possible
 # or try http://technet.microsoft.com/en-us/library/cc722041%28WS.10%29.aspx

 #below is for Desktops (windows 7)

 # install IIS Role
 ocsetup IIS-WebServerRole
 ocsetup IIS-WebServer
 ocsetup IIS-CommonHttpFeatures
 ocsetup IIS-DefaultDocument
 ocsetup IIS-HttpErrors
 ocsetup IIS-HttpRedirect
 ocsetup IIS-StaticContent
 ocsetup IIS-HealthAndDiagnostics
 ocsetup IIS-CustomLogging
 ocsetup IIS-HttpLogging
 ocsetup IIS-LoggingLibraries
   #ocsetup MSMQ-HTTP possbily needed for Ektron
 ocsetup IIS-RequestMonitor
 ocsetup IIS-Performance
 ocsetup IIS-HttpCompressionDynamic
 ocsetup IIS-HttpCompressionStatic
 ocsetup IIS-Security
 ocsetup IIS-BasicAuthentication
 ocsetup IIS-ClientCertificateMappingAuthentication
 ocsetup IIS-IISCertificateMappingAuthentication
 ocsetup IIS-IPSecurity
 ocsetup IIS-RequestFiltering
 ocsetup IIS-WindowsAuthentication
 ocsetup IIS-WebServerManagementTools
 ocsetup IIS-IIS6ManagementCompatibility
 ocsetup IIS-ManagementConsole

 # install .net
 ocsetup NetFx2-ServerCore
 ocsetup NetFx2-ServerCore-WOW64
 ocsetup NetFx3
 
 #install ASP
 ocsetup IIS-ASP
 
 # install asp.net  start /w
 ocsetup WAS-NetFxEnvironment
 ocsetup IIS-ISAPIExtensions
 ocsetup IIS-ISAPIFilter
 ocsetup IIS-NetFxExtensibility
 ocsetup IIS-ASPNET
 ocsetup IIS-ApplicationDevelopment
 ocsetup WCF-HTTP-Activation

}

else
    {write-host "you must select S or L"  
    Exit}


2 comments:

  1. running this script on windows 7 i get a pop-up error for each command

    Setup encountered and error: 0x652
    Another installation is already in progress. Complete that installation
    before proceeding with this install

    seems the problem is that ocsetup runs in the background and in this case we need to wait for each command to complete

    this link
    http://blogs.msdn.com/b/motleyqueue/archive/2007/10/20/unattended-msmq-installation-on-windows-vista.aspx

    says you can prepend the start /wait - and this seems to work when called from a batch file, I could not get it to work from powershell

    tried both
    & "start /wait ocsetup IIS-WebServerRole"
    and
    Start-Process -FilePath ocsetup.exe -ArgumentList "IIS-WebServerRole /norestart" -Wait

    ran into different issues with both

    curious if you ran into similar issues? have not tried the server 2008 installs yet

    ReplyDelete
  2. Hello friends,

    Iis-stff is an integral part of windows server family of products, as well as certain editions of windows XP, windows vista and windows 7. It is not turned on by default when windows is installed. Thanks a lot......

    Windows Auditing

    ReplyDelete