I've got the below Powershell script, and I'm struggling to finish it off.
Get-ChildItem -Path 'C:\temp\xml' -Include '*.xml' |
ForEach-Object
{
$FileName = $_.Fullname
$Pattern = "</Date>"
$FileOriginal = Get-Content $FileName
$date = Get-Date
$DateStr = $date.ToString("yyyyMMdd")
[String[]] $FileModified = @()
Foreach ($Line in $FileOriginal)
{
$FileModified += $Line
if ($Line -match $pattern)
{
$FileModified += "<CDate>$DateStr</CDate>"
}
}
$FileModified = $FileModified -replace "CUR","PIT"
$FileModified = $FileModified -replace "Current","Time"
Set-Content $fileName $FileModified
}
When I attempt to run it, I get the following messages:
cmdlet ForEach-Object at command pipeline position 2
Supply values for the following parameters:
Process[0]:
Can anyone see what I'm doing wrong?