Selecting right audio device for end users using PowerShell script


I work as a junior system admin for a small company. Now, I have been tasked with modifying the default audio settings for our end users using PowerShell Scripts. Currently, whenever we update Windows, by defaults Windows back to HDMI audio, but our monitors do not have speakers and our users are complaining about it. We have sent out a procedure to change audio devices explaining the situation for our end users but it’s not enough.

I am looking for a GPO but not able to find it any and there is not a simple GPO using I can disabling the HDMI audio completely as what we want. I have found a PowerShell script that does a similar part of the work that I need, but I would like to add a few conditions to it.

The problem is I have no idea how to add those conditions as I am a beginner and I don’t know how to code PowerShell. The code currently lists the audio device, if a device with Logitech is found, it sets it as default, if not, it leaves it to what it currently is (HDMI audio), I would like it to then set the Realtek audio device.

Any help is greatly appreciated