【发布时间】:2015-06-05 10:29:32
【问题描述】:
每次我运行下面的脚本时,我都会得到
无法将参数绑定到参数“FilePath”,因为它为空。
昨晚还在工作。没有进行任何更改,今天早上它只是失败了。有趣的是,如果我保存脚本然后运行它,它就可以工作。但是,如果我清除控制台然后再次运行它会失败。
我是否遗漏了一些明显的东西?
New-Item -ItemType Directory -Force -Path C:\NonStandard_Services
set-location C:\NonStandard_Services
$Computers= Get-Content C:\computers.txt
$Report= $file
$file= $Computer
ForEach ($Computer in $Computers)
{
Get-WmiObject -ComputerName $Computer -class Win32_Service -ErrorAction SilentlyContinue |
Where-Object -FilterScript {$_.StartName -ne "LocalSystem"}|
Where-Object -FilterScript {$_.StartName -ne "NT AUTHORITY\NetworkService"} |
Where-Object -FilterScript {$_.StartName -ne "NT AUTHORITY\LocalService"} |
Select-Object -Property StartName,Name,DisplayName|
ConvertTo-Html -Property StartName,Name,DisplayName -head $HTML -body "<H2>Non- Standard Service Accounts on $Computer</H2>"| Out-File $Report -Append}
#Rename-Item c:\GP_Services\Report.htm $file
Get-ChildItem | Where-Object {$_.extension -ne ".htm"} | Rename-Item -newname { $_.name + '.htm' }
【问题讨论】:
-
错误是文件外:无法将参数绑定到参数“FilePath”,因为它为空。在 C:\Users\adminrrahul\Desktop\Svc_Accs Final03.ps1:14 char:135 + ... H2>"| Out-File $Report -Append} + ~~~~~~~ + CategoryInfo : InvalidData: (: ) [Out-File], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.OutFileCommand
标签: powershell