I have this function where I want the output file name should be same as the filename with "_new.log" added to the end. This is my script. it does not work.
Function IIS-CleanUp1($file)
{
Get-Content $file | ? { $_ -match $control -and $_ -notmatch '^\#'} | Out-File $file + "_new.log"
}
IIS-CleanUp1 "u_ex130801.log"
It throws the following error:
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
Any help is much appreciated:
- T