frgnca / AudioDeviceCmdlets

AudioDeviceCmdlets is a suite of PowerShell Cmdlets to control audio devices on Windows
MIT License
743 stars 92 forks source link

Script block not working for 'Set-DefaultAudioDevice' #15

Closed TheEngineerGuy closed 7 years ago

TheEngineerGuy commented 7 years ago

"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
TheEngineerGuy commented 7 years ago

Got it change {} to ()

Command that works "Set-DefaultAudioDevice (Get-AudioDeviceList | Where-Object {$.DeviceFriendlyname -like 'SAMSUNG'} | foreach {$.Index})"

cdhunt commented 7 years ago

👍