Dennisaa

Install-IIS

Mar 8th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .Synopsis
  3.    Install IIS and Windows required features, for 1 or more computers.
  4.    Requires PS3
  5.    Requires Windows 2008 R2 or higher
  6. .Description
  7.    To see the current list of installed features, use [Get-WindowsFeature]
  8.    The system must be rebooted after installation
  9.    To remove a feature, use... Remove-WindowsFeature, eg Remove-WindowsFeature bits
  10. .Example
  11.    Install-IIS -ComputerSet "Dennis2008R2SP1","localhost"
  12. .Example
  13.    Install-IIS "Dennis2008R2SP1","localhost"
  14. .Example
  15.     "Dennis2008R2SP1","localhost" | Install-IIS
  16. #>
  17. function Install-IIS
  18. {
  19.  
  20.     Param (
  21.         [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
  22.         [string[]]
  23.         $ComputerName
  24.     )
  25.  
  26.     Begin {
  27.         Import-Module ServerManager
  28.     }
  29.     Process {
  30.         foreach ($computer in $ComputerName) {
  31.             "Processing [$computer]..."
  32.             $session = New-PSSession -ComputerName $computer
  33.             Invoke-Command -Session $session -ScriptBlock {
  34.                 Add-WindowsFeature Application-Server, NPAS, BITS, Web-Server, Net-Framework, RDS-RD-Server -IncludeAllSubFeature -Restart -Concurrent
  35.             }
  36.             Remove-PSSession $session
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment