Editing Add/Remove Programs Name with toolkit

Hi All,

Running into an issue that I am stuck on. I created the below function in the extensions.ps1 file to search the Uninstall registry keys and use the $appname variable from the toolkits deploy-application.ps1file to search for a display name that matches. Then when it finds it it will edit the display name to match my companies naming scheme.

This works fine if I don’t use the $appname variable. IF I do use the variable it appears to be returning Null. I am thinking I did something wrong in the logic and maybe some fresh eyes would be helpful before I pull my hair out.

function FindAndReplace-DisplayName {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]
$NewName
)
Begin {
[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
}
Process {
$1Reg_Paths = @(“HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”,
“HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”)
foreach ($aPath in $1Reg_Paths) {
$Installed_Application = Get-ChildItem -Path $apath |
ForEach { Get-ItemProperty $.PSPath } |
Where-Object { $
.DisplayName -match “$appName” } |
Select-Object $_
foreach($Application in $Installed_Application)
{
Write-Log -Message “Full Path in the Register”
Write-Log -Message “$Application.PsPath”
Write-Log -Message “Product Code”
Write-Log -Message $Application.PSChildName
Set-ItemProperty -Path $Application.PsPath -Name “DisplayName” -Value $companynamescheme
Write-Log -Message “Display Name of $appName changed to $companynamescheme”
}
}

}
End {
	Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
}

}

When i kick off the function I use this command:
FindAndReplace-DisplayName -NewName “$companynamescheme”

If I replace $appname with say “Acrobat Reader DC” in the above function it works.
If I just leave it as $appname it does not work. This is even though I have already defined $appname = “Acrobat Reader DC” in the deploy-application.ps1.

Any ideas? Is there a better way to do this perhaps?
Thanks

Replace -Match with -Like

-Match is for Regular expressions

Also FYI: "$appNane" -eq $AppName

Uggghhhhh…it was that simple…Thanks so much!! I was going crazy trying to figure it out.