Announcement

Collapse
No announcement yet.
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Powershell to install Server 2008 roles and features

    I have been working on a powershell script to install the required Roles and Features under Windows Server 2008 R2 (Note that this does not work in Windows Server 2008 with Service Pack 2 the original 32bit version).
    This is to try and get some consistency with the configuration of the servers when there are multiple engineers building servers or the build of the server is delegated to the end user.

    There are some things that this script doesn't do either because it can't be done or I haven't worked out how to do it including:
    • Turn off Data Execution Protection
    • Turn off UAC

    These are now covered at the end of the powershell script:
    • Turn off Firewall
    • Turn off Automatic Updates
    • Set SMTP Service startup to Automatic (it is manual by default)


    From a freshly installed copy of Windows Server 2008 R2:
    Click on Start->All Programs->Accessories->Windows Powershell ( not Powershell (x86) )
    Right click and run as administrator on the Powershell application

    Paste the lines below into the powershell window and sit back:

    PHP Code:
    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 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-DAV-Publishing
    Add
    -WindowsFeature Web-App-Dev
    Add
    -WindowsFeature Web-Asp-Net
    Add
    -WindowsFeature Web-Net-Ext
    Add
    -WindowsFeature Web-ASP
    Add
    -WindowsFeature Web-CGI
    Add
    -WindowsFeature Web-ISAPI-Ext
    Add
    -WindowsFeature Web-ISAPI-Filter
    Add
    -WindowsFeature Web-Includes
    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-ODBC-Logging
    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 Web-Mgmt-Compat
    Add
    -WindowsFeature Web-Metabase
    Add
    -WindowsFeature Web-WMI
    Add
    -WindowsFeature Web-Lgcy-Scripting
    Add
    -WindowsFeature Web-Lgcy-Mgmt-Console
    Add
    -WindowsFeature Web-Ftp-Server
    Add
    -WindowsFeature Web-Ftp-Service
    Add
    -WindowsFeature Web-Ftp-Ext
    Add
    -WindowsFeature NET-Framework
    Add
    -WindowsFeature NET-Framework-Core
    Add
    -WindowsFeature NET-Win-CFAC
    Add
    -WindowsFeature NET-HTTP-Activation
    Add
    -WindowsFeature SMTP-Server
    Add
    -WindowsFeature SNMP-Services
    Add
    -WindowsFeature SNMP-Service
    Add
    -WindowsFeature SNMP-WMI-Provider
    Add
    -WindowsFeature Telnet-Client
    Add
    -WindowsFeature WAS
    Add
    -WindowsFeature WAS-Process-Model
    Add
    -WindowsFeature WAS-NET-Environment
    Add
    -WindowsFeature WAS-Config-APIs
    Add
    -WindowsFeature AS-Ent-Services
    Add
    -WindowsFeature AS-Dist-Transaction
    Set
    -Service MpsSvc -StartupType disabled
    Set
    -Service wuauserv -StartupType disabled
    Set
    -Service SMTPSVC -StartupType Automatic 
    Change Log: April 17th 2013 - added Set-Service SMTPSVC -StartupType Automatic to the end of the script.
    Last edited by ShoreTel_Dave; 04-21-2013, 03:45 PM. Reason: Removed unneeded RSAT Components. Updated to disable updates and firewall. Added COM+ and Distributed Transactions, Win2k8 R2

  • #2
    This is a GREAT idea. I hope you share your tweaking as you fine tune it. I'm going to try this out on a test setup when I get a chance.

    Comment


    • #3
      Server Specs: Server 2008 R2 x64 (VM), 4GB RAM, 20GB HD

      Everything installed fine with the following exeptions:

      Code:
      PS C:\Users\Administrator> Add-WindowsFeature RSAT
      Add-WindowsFeature : To install Active Directory Rights Management Services Tools, this server must be joined to a doma
      in. Before you can continue, you must join this server to a domain. Cancel this wizard, join the server to a domain, an
      d then run the wizard again.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT
          + CategoryInfo          : InvalidOperation: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : ConfirmActionOrVetoFailed,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureComm
         and
      Add-WindowsFeature : Install was cancelled.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT
          + CategoryInfo          : OperationStopped: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : AbortAdd,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
      
      Success Restart Needed Exit Code Feature Result
      ------- -------------- --------- --------------
      False   No             Failed    {}
      Code:
      PS C:\Users\Administrator> Add-WindowsFeature RSAT-Role-Tools
      Add-WindowsFeature : To install Active Directory Rights Management Services Tools, this server must be joined to a doma
      in. Before you can continue, you must join this server to a domain. Cancel this wizard, join the server to a domain, an
      d then run the wizard again.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT-Role-Tools
          + CategoryInfo          : InvalidOperation: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : ConfirmActionOrVetoFailed,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureComm
         and
      Add-WindowsFeature : Install was cancelled.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT-Role-Tools
          + CategoryInfo          : OperationStopped: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : AbortAdd,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
      
      Success Restart Needed Exit Code Feature Result
      ------- -------------- --------- --------------
      False   No             Failed    {}
      Code:
      PS C:\Users\Administrator> Add-WindowsFeature RSAT-Feature-Tools
      Add-WindowsFeature : To install BitLocker Recovery Password Viewer, this server must be joined to a domain. Before you
      can continue, you must join this server to a domain. Cancel this wizard, join the server to a domain, and then run the
      wizard again.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT-Feature-Tools
          + CategoryInfo          : InvalidOperation: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : ConfirmActionOrVetoFailed,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureComm
         and
      Add-WindowsFeature : Install was cancelled.
      At line:1 char:19
      + Add-WindowsFeature <<<<  RSAT-Feature-Tools
          + CategoryInfo          : OperationStopped: (:) [Add-WindowsFeature], Exception
          + FullyQualifiedErrorId : AbortAdd,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
      
      Success Restart Needed Exit Code Feature Result
      ------- -------------- --------- --------------
      False   No             Failed    {}

      Thoughts?

      Comment


      • #4
        Originally posted by bhaikalis View Post
        Thoughts?
        Yeah, I'll remove those components. They are for remote management of other servers and are not required.

        Comment


        • #5
          The following will disabled the windows firewall service

          PS C:\Users\Administrator> Get-Service

          Code:
          Status      Name                 DisplayName
          ------      ----                 -----------
          Stopped     MpsSvc               Windows Firewall
          Code:
          Set-Service MpsSvc -StartupType disabled

          Comment


          • #6
            This will turn off windows updates (don't think it's really necessary to have this off though)

            Code:
            Set-Service wuauserv -StartupType disabled

            Comment


            • #7
              Sweeett!
              I'll add those to the end of the script above.

              Comment


              • #8
                This is awesome! I'm building a new server and just used this, I'll let you know how it goes in the next day or so.

                Comment


                • #9
                  Originally posted by CelticTech View Post
                  This is awesome! I'm building a new server and just used this, I'll let you know how it goes in the next day or so.
                  Thank you!
                  Now if only everybody used the same hardware for physical servers, I could try and take the trouble to build a bootable DVD to image the server. For now this still saves quite a bit of effort.

                  Comment


                  • #10
                    Looks good Dave, I just finished up the Director install and initial config - no errors or hangs during install and everything seems to be running smooth.

                    Comment


                    • #11
                      I know ShoreTel is dropping 2003 server support with version 13 but here's a download to Powershell for Server 2003:

                      Download: Update for Windows Server 2003 (KB968930) - Microsoft Download Center - Download Details

                      I'll see if your script works on it and change it around if needed soon once I get another virtual machine built here to test on.

                      Comment


                      • #12
                        Originally posted by CelticTech View Post
                        I know ShoreTel is dropping 2003 server support with version 13 but here's a download to Powershell for Server 2003:

                        Download: Update for Windows Server 2003 (KB968930) - Microsoft Download Center - Download Details

                        I'll see if your script works on it and change it around if needed soon once I get another virtual machine built here to test on.
                        I doubt if it will work as is under Server 2003. The equivalent components don't exist in Server 2003, or the names are different.

                        Comment


                        • #13
                          Just a small addendum.
                          If you are running on a 64bit platform you need to choose "Windows PowerShell" and not "Windows PowerShell (x86)"

                          Comment


                          • #14
                            I have turned ShoreTel_Dave's PowerShell commands into an actual PowerShell Script.

                            To use, just download the file and remove the .txt extension.

                            In PowerShell run "Set-ExecutionPolicy RemoteSigned" first to allow running of local scripts, then run ShoreTelPrereqs.ps1.

                            The script will confirm that you want to "Install Windows Server 2008 Roles and Features for ShoreTel 12? [Y/N]". If you say yes, it's off and running.
                            Attached Files
                            Last edited by activitie; 07-11-2012, 10:46 PM.

                            Comment


                            • #15
                              Great work - Thank you.

                              The following 2 roles are not on it though and have to be added manually for 2008 Server Std 64

                              Com+ Network Access
                              Distributed Transactions

                              Comment

                              Working...
                              X