我需要使用Powershell启用两个Windows功能.但我不知道他们的名字或如何找到他们.

到目前为止,我已设法安装IIS并使用此处找到的脚本停止默认应用程序池.
function InstallFeature($name) {
cmd /c "ocsetup $name /passive"
}
InstallFeature IIS-WebServerRole
InstallFeature IIS-WebServer
InstallFeature IIS-CommonHttpFeatures
InstallFeature IIS-DefaultDocument
InstallFeature IIS-DirectoryBrowsing
InstallFeature IIS-HttpErrors
InstallFeature IIS-HttpRedirect
InstallFeature IIS-StaticContent
InstallFeature IIS-HealthAndDiagnostics
InstallFeature IIS-CustomLogging
InstallFeature IIS-HttpLogging
InstallFeature IIS-HttpTracing
InstallFeature IIS-LoggingLibraries
InstallFeature IIS-Security
InstallFeature IIS-RequestFiltering
InstallFeature IIS-WindowsAuthentication
InstallFeature IIS-ApplicationDevelopment
InstallFeature IIS-NetFxExtensibility
InstallFeature IIS-ISAPIExtensions
InstallFeature IIS-ISAPIFilter
InstallFeature IIS-ASPNET
InstallFeature IIS-WebServerManagementTools
InstallFeature IIS-ManagementConsole
InstallFeature IIS-ManagementScriptingTools
import-module WebAdministration
Stop-WebAppPool DefaultAppPool
Run Code Online (Sandbox Code Playgroud)
解
寻找:
Get-WindowsFeature *ASP*
Get-WindowsFeature *activation*
Run Code Online (Sandbox Code Playgroud)
安装:
Add-WindowsFeature NET-Framework-45-ASPNET
Add-WindowsFeature NET-HTTP-Activation
Run Code Online (Sandbox Code Playgroud)
Gre*_*ray 33
对于较新的Windows客户端操作系统(Windows 10/8.1/8),您无法使用Install-WindowsFeature,因为它仅用于管理服务器上的功能.尝试使用它将导致错误消息:
Get-WindowsFeature:指定cmdlet的目标不能是基于Windows客户端的操作系统.
有一个DISM Powershell模块,您可以使用它来查找和安装可选功能:
gcm -module DISM #List available commands
Get-WindowsOptionalFeature -online | ft #List all features and status
Enable-WindowsOptionalFeature -online -FeatureName NetFx3 -Source e:\Sources\sxs
Run Code Online (Sandbox Code Playgroud)
-Source e:\Sources\sxs仅在该功能需要引用源文件的安装介质时才需要最后一个命令(通常是修复错误:0x800f081f无法找到源文件)..NET Framework 3.5版似乎是唯一一个要求客户端操作系统,但是在服务器操作系统上还有许多其他需要引用安装介质的源.
Loï*_*HEL 21
如果您在Windows 2008R2中有一个模块:
Import-Module servermanager
该模块出口3周的cmdlet: Get-WindowsFeature,Add-WindowsFeature和remove-WindowsFeature
所以你可以做些什么
get-windowsfeature *frame*来列出.net功能并通过命令安装它
Add-WindowsFeature Net-Framework
试试这个以获取名称(简短)和显示名称(长描述):
get-windowsfeature | format-table -property name,displayname -AutoSize
使用它来安装它们:
Install-WindowsFeature -Name $ Name
其中$ Name是get中的name属性
PS:Install-WindowsFeature已取代Add-WindowsFeature
| 归档时间: |
|
| 查看次数: |
53210 次 |
| 最近记录: |