【发布时间】:2013-09-05 14:55:44
【问题描述】:
我有这个函数,我希望输出文件名应该与最后添加“_new.log”的文件名相同。这是我的脚本。它不起作用。
Function IIS-CleanUp1($file)
{
Get-Content $file | ? { $_ -match $control -and $_ -notmatch '^\#'} | Out-File $file + "_new.log"
}
IIS-CleanUp1 "u_ex130801.log"
它会抛出以下错误:
Out-File : Cannot validate argument on parameter 'Encoding'. The argument "+" does not belong to the set "unicode,utf7,
utf8,utf32,ascii,bigendianunicode,default,oem" specified by the ValidateSet attribute. Supply an argument that is in th
e set and then try the command again.
At C:\ShiyamTemp\IIS_CCHECK_AUG\IIS.ps1:3 char:79
+ Get-Content $file | ? { $_ -match $control -and $_ -notmatch '^\#'} | Out-File <<<< $file + "_new.log"
+ CategoryInfo : InvalidData: (:) [Out-File], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.OutFileCommand
非常感谢任何帮助:
- T
【问题讨论】:
标签: powershell output