我想開發一個 powershell 腳本來選擇一堆這些服務器功能和角色是可重復的,因為我使用的許多服務器都需要預先設定相同的設定。我很難在 RegEdit 中找到這些。有人能指出這些角色所在的正確方向嗎?我想我可能沒有在正確的位置尋找。

uj5u.com熱心網友回復:
這可以通過 powershell 使用命令輕松完成 Get-WindowsFeature
PS C:\> Get-WindowsFeature | where installed
Display Name Name Install State
------------ ---- -------------
[X] File and Storage Services FileAndStorage-Services Installed
[X] File and iSCSI Services File-Services Installed
[X] File Server FS-FileServer Installed
[X] Storage Services Storage-Services Installed
[X] Web Server (IIS) Web-Server Installed
[X] Web Server Web-WebServer Installed
[X] Common HTTP Features Web-Common-Http Installed
[X] Default Document Web-Default-Doc Installed
[X] Directory Browsing Web-Dir-Browsing Installed
[X] HTTP Errors Web-Http-Errors Installed
[X] Static Content Web-Static-Content Installed
[X] HTTP Redirection Web-Http-Redirect Installed
[X] WebDAV Publishing Web-DAV-Publishing Installed
[X] Health and Diagnostics Web-Health Installed
[X] HTTP Logging Web-Http-Logging Installed
[X] Custom Logging Web-Custom-Logging Installed
[X] Logging Tools Web-Log-Libraries Installed
[X] Tracing Web-Http-Tracing Installed
[X] Performance Web-Performance Installed
[X] Static Content Compression Web-Stat-Compression Installed
[X] Dynamic Content Compression Web-Dyn-Compression Installed
[X] Security Web-Security Installed
[X] Request Filtering Web-Filtering Installed
[X] Basic Authentication Web-Basic-Auth Installed
[X] Centralized SSL Certificate Support Web-CertProvider Installed
[X] Client Certificate Mapping Authentic... Web-Client-Auth Installed
[X] Digest Authentication Web-Digest-Auth Installed
[X] IIS Client Certificate Mapping Authe... Web-Cert-Auth Installed
[X] IP and Domain Restrictions Web-IP-Security Installed
[X] URL Authorization Web-Url-Auth Installed
[X] Windows Authentication Web-Windows-Auth Installed
[X] Application Development Web-App-Dev Installed
[X] .NET Extensibility 3.5 Web-Net-Ext Installed
[X] .NET Extensibility 4.6 Web-Net-Ext45 Installed
[X] Application Initialization Web-AppInit Installed
[X] ASP Web-ASP Installed
[X] ASP.NET 3.5 Web-Asp-Net Installed
[X] ASP.NET 4.6 Web-Asp-Net45 Installed
[X] CGI Web-CGI Installed
[X] ISAPI Extensions Web-ISAPI-Ext Installed
[X] ISAPI Filters Web-ISAPI-Filter Installed
[X] Server Side Includes Web-Includes Installed
[X] WebSocket Protocol Web-WebSockets Installed
[X] Management Tools Web-Mgmt-Tools Installed
[X] IIS Management Console Web-Mgmt-Console Installed
[X] .NET Framework 3.5 Features NET-Framework-Features Installed
[X] .NET Framework 3.5 (includes .NET 2.0 and 3.0) NET-Framework-Core Installed
[X] .NET Framework 4.6 Features NET-Framework-45-Fea... Installed
[X] .NET Framework 4.6 NET-Framework-45-Core Installed
[X] ASP.NET 4.6 NET-Framework-45-ASPNET Installed
[X] WCF Services NET-WCF-Services45 Installed
[X] HTTP Activation NET-WCF-HTTP-Activat... Installed
[X] Message Queuing (MSMQ) Activation NET-WCF-MSMQ-Activat... Installed
[X] Named Pipe Activation NET-WCF-Pipe-Activat... Installed
[X] TCP Activation NET-WCF-TCP-Activati... Installed
[X] TCP Port Sharing NET-WCF-TCP-PortShar... Installed
[X] Message Queuing MSMQ Installed
[X] Message Queuing Services MSMQ-Services Installed
[X] Message Queuing Server MSMQ-Server Installed
[X] Remote Differential Compression RDC Installed
[X] SMB 1.0/CIFS File Sharing Support FS-SMB1 Installed
[X] Windows Defender Features Windows-Defender-Fea... Installed
[X] Windows Defender Windows-Defender Installed
[X] GUI for Windows Defender Windows-Defender-Gui Installed
[X] Windows PowerShell PowerShellRoot Installed
[X] Windows PowerShell 5.1 PowerShell Installed
[X] Windows PowerShell 2.0 Engine PowerShell-V2 Installed
[X] Windows PowerShell ISE PowerShell-ISE Installed
[X] Windows Process Activation Service WAS Installed
[X] Process Model WAS-Process-Model Installed
[X] .NET Environment 3.5 WAS-NET-Environment Installed
[X] Configuration APIs WAS-Config-APIs Installed
[X] WoW64 Support WoW64-Support Installed
并將其安裝到另一臺機器上,您只需要將結果通過管道傳輸到Install-WindowsFeaturewith 屬性ComputerName
Get-WindowsFeature | where installed | Install-WindowsFeature -ComputerName $computername
另一種選擇是使用安裝 Windows 功能 ConfigurationFilePath
PS> $servers = ('server1', 'server2')
PS> foreach ($server in $servers) {Install-WindowsFeature -ConfigurationFilePath D:\ConfigurationFiles\ADCSConfigFile.xml -ComputerName $server}
通過單擊服務器管理器中添加角色和功能向導的確認安裝選擇頁面上的匯出配置設定來創建組態檔。在第一行,設定了 $servers 變數的值;在第二行,ADCSConfigFile.xml 組態檔中的安裝說明適用于在 $servers 中命名的每個服務器。
參考:https : //docs.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature? view = windowsserver2022- ps
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/407470.html
標籤:
