Script block not working for 'Set-DefaultAudioDevice'
TheEngineerGuy opened this issue · 2 comments
"Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index}" returns value 4.
However, when I run "Set-DefaultAudioDevice {Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index}}", the index 0 gets set.
Copy paste from PowerShell window is as below:
PS C:\Windows\system32> Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index}
4
PS C:\Windows\system32> Set-DefaultAudioDevice {Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index}}
Index DeviceFriendlyname Device
0 Speakers (Realtek High Definition Audio) CoreAudioApi.MMDevice
Got it change {} to ()
Command that works "Set-DefaultAudioDevice (Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index})"
👍