得到“找不到驱动器.名为“IIS"的驱动器不存在." [英] Getting "Can't find the drive. The drive called 'IIS' does not exist."

查看:22
本文介绍了得到“找不到驱动器.名为“IIS"的驱动器不存在."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 PowerShell 脚本来自动部署 IIS 网站,但是当我将参数传递给脚本时,我收到以下错误:

I wrote a PowerShell script to deploy IIS Website automatically, but when I pass parameters to the script I get the following error:

找不到驱动器.名为IIS"的驱动器不存在.

Cannot find the drive. The drive called 'IIS' does not exist.

我的脚本(iss_website_version_update.ps1)如下,但请注意它还没有完成:

My script (iss_website_version_update.ps1) is as below, but note that it is not finished yet:

param(
[array]$iishostlist=$(throw "Parameter missing: -name iishostlist"),
[array]$websiteName=$(throw "Parameter missing: -name websiteName")
)

For($i=0;$i -lt $iishostlist.Count; $i++){
For($j=0;$j -lt  $websiteName.Count; $j++){
    $start = get-date
    $tempSession = new-pssession  -ComputerName  $($iishostlist[$i])
    Invoke-Command -Session $tempSession -ScriptBlock {
        C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -NonInteractive -command Import-Module WebAdministration;set-location IIS:;(Stop-Website $($websiteName[$j]))
        }
    .......

请告诉我为什么不能识别命令Invoke-Command中的子命令set-location IIS:;?

Please let me know why the sub-command set-location IIS:; in the command Invoke-Command is not be recognized ?

推荐答案

驱动由WebAdministration模块提供,所以需要先安装/导入该模块.

The drive is provided by the WebAdministration module, so you need to install/import that module first.

如何安装模块取决于您的实际系统以及您使用的是 GUI 还是 PowerShell.例如,在 Windows Server 2008 R2 上,您将使用以下 PowerShell 命令安装模块:

How you install the module depends on your actual system and whether you use GUI or PowerShell. On a Windows Server 2008 R2 for instance you'd install the module with the following PowerShell commands:

Import-Module ServerManager
Add-WindowsFeature Web-Scripting-Tools

安装模块后,您可以像这样在脚本中加载它:

After the module is installed you can load it in your script like this:

Import-Module WebAdministration

这篇关于得到“找不到驱动器.名为“IIS"的驱动器不存在."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆