I created a log file using powershell in .txt or .config. Its look like :
# Hello
## This is readme.txt file
## This is commented line
# This is powershell command output
#
# File generated for read, re-load and edit the values
## -- many more comment is there
# Users can change values..
## There is no relation between $RegPath and $RegValue, this are only variables.
# this are registry path,
$RegPath = (
"\\hklm\software\microsoft\123",
"\\hklm\software\Adobe\123",
"\\hklm\software\Fax\123",
"\\hklm\software\IE\123");
# this are registry value.
$RegValue = (
"0",
"123",
"abc",
"456asdccxv",
"update",
"serv");
#this are some services with 0/1
# Win 7 OS exist
$IsWin7OS = 1
# Service pack installed
$IsSPInstalled = 0
# Check office
$MSOffice = 1
# This setting name is
$SettingName = "ReadMe.txt"
This is sample ReadMe.txt. I want to read this file in powershell and want to get values of $RegPath, $RegValue, $IsWin7OS, $IsSPInstalled, $MSOffice and $SettingName in powershell platform. Then I will update this value and save again in same file.
rn", '(' -replace "rn)", ')' -split "rn" | % { $a = $_ -split '\s*=\s*' if ( $a[1].SubString(0, 1) -eq '(' ) { New-Variable $a[0] ($a[1] -replace '[()]' -split ',') } else { New-Variable $a[0] $a[1] } } Write-Host "RegValues:" $RegValues Write-Host "RegServices:" $RegServices Write-Host "IsWin7OS:" $IsWin7OS Write-Host "IsSPInstalled:" $IsSPInstalled But when I run this code 2nd time is gives error