草庐IT

windows - 自动安装 IIS

coder 2023-11-11 原文

目标是在新的 Windows 工作站(如 Windows 10)上为 .NET 开发环境自动启用 IIS。我知道可以编写 Powershell 脚本来执行类似的操作,但我不知道从哪里开始。

我意识到我可以很容易地进入控制面板并在那里启用服务,但是运行脚本来执行此操作似乎更有效。

在 Powershell 中运行以启用 IIS 的示例脚本是什么样的?

最佳答案

服务器操作系统

在 Windows Server 上,您可以运行以下命令来自动安装 IIS:

#-LogPath can be added if you want a log to be created of the installation
#-Restart can be added if you want to auto restart after installation
Install-WindowsFeature -ComputerName SomePCHere -Name Web-Server

从 PowerShell 的角度来看,以下是 IIS 功能的名称:

Display Name                                            Name                 
------------                                            ----                      
    [ ] Web Application Proxy                           Web-Application-Proxy          
[ ] Web Server (IIS)                                    Web-Server                     
    [ ] Web Server                                      Web-WebServer                  
        [ ] Common HTTP Features                        Web-Common-Http                
            [ ] Default Document                        Web-Default-Doc                
            [ ] Directory Browsing                      Web-Dir-Browsing               
            [ ] HTTP Errors                             Web-Http-Errors                
            [ ] Static Content                          Web-Static-Content             
            [ ] HTTP Redirection                        Web-Http-Redirect              
            [ ] WebDAV Publishing                       Web-DAV-Publishing             
        [ ] Health and Diagnostics                      Web-Health                     
            [ ] HTTP Logging                            Web-Http-Logging               
            [ ] Custom Logging                          Web-Custom-Logging             
            [ ] Logging Tools                           Web-Log-Libraries              
            [ ] ODBC Logging                            Web-ODBC-Logging               
            [ ] Request Monitor                         Web-Request-Monitor            
            [ ] Tracing                                 Web-Http-Tracing               
        [ ] Performance                                 Web-Performance                
            [ ] Static Content Compression              Web-Stat-Compression           
            [ ] Dynamic Content Compression             Web-Dyn-Compression            
        [ ] Security                                    Web-Security                   
            [ ] Request Filtering                       Web-Filtering                  
            [ ] Basic Authentication                    Web-Basic-Auth                 
            [ ] Centralized SSL Certificate Support     Web-CertProvider               
            [ ] Client Certificate Mapping Authentic... Web-Client-Auth                
            [ ] Digest Authentication                   Web-Digest-Auth                
            [ ] IIS Client Certificate Mapping Authe... Web-Cert-Auth                  
            [ ] IP and Domain Restrictions              Web-IP-Security                
            [ ] URL Authorization                       Web-Url-Auth                   
            [ ] Windows Authentication                  Web-Windows-Auth               
        [ ] Application Development                     Web-App-Dev                    
            [ ] .NET Extensibility 3.5                  Web-Net-Ext                    
            [ ] .NET Extensibility 4.5                  Web-Net-Ext45                  
            [ ] Application Initialization              Web-AppInit                    
            [ ] ASP                                     Web-ASP                        
            [ ] ASP.NET 3.5                             Web-Asp-Net                    
            [ ] ASP.NET 4.5                             Web-Asp-Net45                  
            [ ] CGI                                     Web-CGI                        
            [ ] ISAPI Extensions                        Web-ISAPI-Ext                  
            [ ] ISAPI Filters                           Web-ISAPI-Filter               
            [ ] Server Side Includes                    Web-Includes                   
            [ ] WebSocket Protocol                      Web-WebSockets                 
    [ ] FTP Server                                      Web-Ftp-Server                 
        [ ] FTP Service                                 Web-Ftp-Service                
        [ ] FTP Extensibility                           Web-Ftp-Ext                    
    [ ] Management Tools                                Web-Mgmt-Tools                 
        [ ] IIS Management Console                      Web-Mgmt-Console               
        [ ] IIS 6 Management Compatibility              Web-Mgmt-Compat                
            [ ] IIS 6 Metabase Compatibility            Web-Metabase                   
            [ ] IIS 6 Management Console                Web-Lgcy-Mgmt-Console          
            [ ] IIS 6 Scripting Tools                   Web-Lgcy-Scripting             
            [ ] IIS 6 WMI Compatibility                 Web-WMI                        
        [ ] IIS Management Scripts and Tools            Web-Scripting-Tools            
        [ ] Management Service                          Web-Mgmt-Service               
[ ] IIS Hostable Web Core                               Web-WHC 

在“名称”参数上用逗号分隔您希望安装的每个功能。示例:

Install-WindowsFeature -ComputerName SomePCHere -Name Web-Server, Web-Mgmt-Tools, Web-Security

客户端操作系统

在 Windows 8.1+ 上,您可以使用 Get-WindowsOptionalFeatureEnable-WindowsOptionalFeature 安装 IIS。

通过运行以下命令,您可以从 PowerShell 的角度获取 IIS 功能的名称:

PS C:\> Get-WindowsOptionalFeature -online | Where {$_.FeatureName -like 'IIS*'} | Sort FeatureName | Format-Table

FeatureName                                   State
-----------                                   -----
IIS-ApplicationDevelopment                 Disabled
IIS-ApplicationInit                        Disabled
IIS-ASP                                    Disabled
IIS-ASPNET                                 Disabled
IIS-ASPNET45                               Disabled
IIS-BasicAuthentication                    Disabled
IIS-CertProvider                           Disabled
IIS-CGI                                    Disabled
IIS-ClientCertificateMappingAuthentication Disabled
IIS-CommonHttpFeatures                     Disabled
IIS-CustomLogging                          Disabled
IIS-DefaultDocument                        Disabled
IIS-DigestAuthentication                   Disabled
IIS-DirectoryBrowsing                      Disabled
IIS-FTPExtensibility                       Disabled
IIS-FTPServer                              Disabled
IIS-FTPSvc                                 Disabled
IIS-HealthAndDiagnostics                   Disabled
IIS-HostableWebCore                        Disabled
IIS-HttpCompressionDynamic                 Disabled
IIS-HttpCompressionStatic                  Disabled
IIS-HttpErrors                             Disabled
IIS-HttpLogging                            Disabled
IIS-HttpRedirect                           Disabled
IIS-HttpTracing                            Disabled
IIS-IIS6ManagementCompatibility            Disabled
IIS-IISCertificateMappingAuthentication    Disabled
IIS-IPSecurity                             Disabled
IIS-ISAPIExtensions                        Disabled
IIS-ISAPIFilter                            Disabled
IIS-LegacyScripts                          Disabled
IIS-LegacySnapIn                           Disabled
IIS-LoggingLibraries                       Disabled
IIS-ManagementConsole                      Disabled
IIS-ManagementScriptingTools               Disabled
IIS-ManagementService                      Disabled
IIS-Metabase                               Disabled
IIS-NetFxExtensibility                     Disabled
IIS-NetFxExtensibility45                   Disabled
IIS-ODBCLogging                            Disabled
IIS-Performance                            Disabled
IIS-RequestFiltering                       Disabled
IIS-RequestMonitor                         Disabled
IIS-Security                               Disabled
IIS-ServerSideIncludes                     Disabled
IIS-StaticContent                          Disabled
IIS-URLAuthorization                       Disabled
IIS-WebDAV                                 Disabled
IIS-WebServer                              Disabled
IIS-WebServerManagementTools               Disabled
IIS-WebServerRole                          Disabled
IIS-WebSockets                             Disabled
IIS-WindowsAuthentication                  Disabled
IIS-WMICompatibility                       Disabled

类似于 windows 服务器,您可以通过运行以下或类似的东西来安装上述功能(您可以使用逗号分隔 FeatureName 参数上的值来安装多个功能:

#you can add -NoRestart to prevent automatic restarting (if required)
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Webserver

希望对您有所帮助!

关于windows - 自动安装 IIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37892173/

有关windows - 自动安装 IIS的更多相关文章

  1. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  2. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  3. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  4. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  5. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  6. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  7. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  8. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  9. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  10. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

随机推荐