I've been a vbscripter for years and am moving to Posh for everything. I have a tool I need to write and am trying to figure out the [regex] to extract rows from a file and write to a different file.
I first preload 2 files with
Dates in this fomat
The beginning of the script prompts for the present date 20120405 then the 1000
It builds a directory and file using the date and time.
Then I get the Array of file names in the folders from the date that exist in another directory and get the Array of machine names
I need to read the files and compair the first 8 characters of each row to the Array of machine names if the first 8 characters are equal to the machine, write that row to the file I created.
I'm not sure how to do the [regex], to limit it to the first 8 characters only.
The script so far...
$ADate = Read-Host "Enter today's date in YYYYMMDD format"
$MachineFile = 'D:\_Scripts\PowerShell\TLFParsing\MACHINE.TXT'
$DateFolderFile = 'D:\_Scripts\PowerShell\TLFParsing\DATE.TXT'
$WriteFile = 'D:\_Scripts\PowerShell\TLFParsing\TEMP\'
New-Item $WriteFile\$ADate -type directory
$ATime = Read-Host 'Enter The Time - Example 0941 -'
New-Item $WriteFile\$ADate\tlf$ADate$ATime.xmt -type file
$DateFolderArry = Get-Content $DateFolderFile
foreach($DateFolder in $DateFolderArry)
$FileName = [IO.Directory]::GetFiles("D:\CSAS\Archives\" + $DateFolder);
foreach($Row in $FileName)
$MachineArry = Get-Content $MachineFile
foreach($ATM in $MachineArry)