Hi,
What is the format of the properties files? If it's plain text you can use the out-file cmdlet to write to the files.
Out-File (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi I have some servers and we have two properties file `1.security.properties and glb.properties.
In those files i have to add environments like if our product is upsEnvironment=ups
condition is if already environment/properties exist in server no need to add if not script needs to add.
Please help me on this
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.
Hi,
What is the format of the properties files? If it's plain text you can use the out-file cmdlet to write to the files.
Out-File (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
please help me for this script
Requirements : 1. I need compare two file contents and if already exist then script should skip otherwise we need to add content to the file
$FilePath = "C:\test\security.properties.txt"
$FileContents = Get-Content -Path $FilePath
$i = 1
# Read the file line by line
ForEach ($Line in $FileContents) {
# Process each line here
Write-Host "Line# $i :" $Line
$i++
if($i -match $([string]$akm))
{
$file = "C:\test\security.properties.txt"
Add-Content $file "absEnvironment=abs"
}
}
This script does not compare files. Do you want to make sure 1.security.properties and glb.properties are identical? What is $akm? Please note that the regular expression should be on the right-hand side of the -match operator.