【发布时间】:2014-08-13 10:01:53
【问题描述】:
我想将我的 IIS Bidings 输出到 csv 或 txt,我只是在使用该 cmdlet 玩了一下:
Get-ChildItem -path IIS:\Sites
完美运行,使用此命令输出到 .txt 也很完美:
Get-ChildItem -path IIS:\Sites | out-file "D:\_utils\PowerShell Scripts\IISexport\IISExport.txt"
但是,一旦我将它包装到一个函数中,powershell 就会尝试找到物理路径 IIS:\Sites,这当然不存在。
Get-ChildItem : Cannot find drive. A drive with the name 'IIS' does not exist.
At D:\_utils\PowerShell Scripts\IISReport.ps1:8 char:1
到目前为止,我的脚本非常简单:
$today = Get-Date -format M.d.yyyy
function IISexport
{
Get-ChildItem -path IIS:\Sites
}
IISexport | out-file "D:\_utils\PowerShell Scripts\IISexport\IISExport$today.txt"
我错过了什么?我想把它排除在外,因为我想把它放到一个更大的脚本中,从 xx 网络服务器中排除我的网络绑定。
我认为这与控制台中已经给出但不在我的脚本中的环境变量有关。但我不知道如何管理它们。已经试过get-childitem evn:
这给我带来了很多变数。
【问题讨论】:
标签: powershell iis powershell-4.0 web-administration