PowerShell Windows 2008缺少模块

时间:2016-09-17 15:08:30

标签: powershell windows-server-2008

如果这是一个NOOB问题,我很抱歉,但是我在Windows 10盒子上写了一个PowerShell脚本,我试图在2008年的盒子上运行脚本。在新安装的2008盒子上,我不得不添加windows powershell功能。我的最终目标是安装Web服务器(IIS)管理Cmdlet

PS C:\Users\Administrator> Get-Module -ListAvailable | Import-Module
PS C:\Users\Administrator> Get-Module -ListAvailable

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Manifest   BitsTransfer              {}
Manifest   PSDiagnostics             {Enable-PSTrace, Enable-WSManTrace,  Start-Trace, Disable-PSWSManCombined...


PS C:\Users\Administrator>
PS C:\Users\Administrator> add-pssnapin WebAdministration
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At line:1 char:13
+ add-pssnapin <<<<  WebAdministration
+ CategoryInfo          : InvalidArgument: (WebAdministration:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

PS C:\Users\Administrator>
PS C:\Users\Administrator> Import-Module WebAdministration
Import-Module : The specified module 'WebAdministration' was not loaded because no valid module file was found in any module directory.
At line:1 char:14
+ Import-Module <<<<  WebAdministration
+ CategoryInfo          : ResourceUnavailable: (WebAdministration:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId :Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

Windows Server 2008没有附带PowerShell模块来管理IIS。 Windows Server 2008 R2添加了该功能。您需要download并先安装它。有关详细信息,请参阅here。另请参阅this related question

答案 1 :(得分:1)

您需要在WebAdministration - 模块可用之前安装IIS管理工具。尝试(在Win10上测试):

Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerManagementTools" -All