functions/Set-JavaProperty.ps1

<#
.Synopsis
  Sets a Java configuration property in a Java Property File
 
.Description
  Sets a Java configuration property in a Java Property File
 
.Parameter PropertyFile
 The name of the property file to update
 
.Parameter property
 The Name of the volume to mount
   
 
.Example
  Set-JavaProperty -PropertyFile "$PSScriptRoot\buildAgent.properties" -Property "name" -Value "AWS-TMCTY-03"
#>


function Set-JavaProperty
{
    param (
        [Parameter(Mandatory=$true)] [string] $PropertyFile,
        [Parameter(Mandatory=$true)] [string] $Property,
        [Parameter(Mandatory=$true)] [string] $Value
    )
    

    $file_content = Get-Content $PropertyFile
    $pattern = "(?-s)(?<=$($property)=).+"
 
    $filecontentOutput = $file_content -replace  $pattern , $Value
    
    Set-Content -Path $PropertyFile -Value $filecontentOutput
} 

Export-ModuleMember -Function Set-JavaProperty