Based on my research and as the command works for you (as per your comment), here is the final script that may work as 'one gesture'. I've added at the begining some instruction to run as admin automatically (self elevated). This will only works if the user is admin of the computer, of course.
The final script, you may save as '.ps1' file, and execute with PowerShell :
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
if ($myWindowsPrincipal.IsInRole($adminRole))
{
# We are running "as Administrator" - so change the title and background color to indicate this
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"
$Host.UI.RawUI.BackgroundColor = "DarkBlue"
clear-host
}
else
{
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
exit
}
Get-PnpDevice -FriendlyName "Intel(R) Display Audio" | Disable-PnpDevice -confirm:$false
Get-PnpDevice -FriendlyName "Intel(R) Display Audio" | Enable-PnpDevice -confirm:$false
I was not able to find a solution without Devcon or a PowerShell module to download. Here is an article explaining how to disable a device with PowerShell, using a simple module to import : https://blog.kulman.sk/enabling-and-disabling-hardware-devices-with-powershell/
– Ob1lan – 2017-01-11T08:49:36.6832Hey, on Windows 10 I found something that might interrest you : Get-PnpDevice. Try to use this command to get the FriendlyName of your sound device, then try something like this : Get-PnpDevice -FriendlyName "My USB Audio Device" | Disable-PnpDevice -confirm:$false – Ob1lan – 2017-01-11T11:51:17.393
1
@Ob1lan It works on my system, with
– Fuhrmanator – 2017-01-11T19:53:32.227Get-PnpDevice -FriendlyName "Intel(R) Display Audio" | Disable-PnpDevice -confirm:$false; Get-PnpDevice -FriendlyName "Intel(R) Display Audio" | Enable-PnpDevice -confirm:$false
-- I put this in a.ps1
file, then a shortcut per http://stackoverflow.com/a/10137272/1168342 - I didn't quite figure out how make it run always as requesting admin, but right-clicking the shortcut allows that option. Not quite one gesture, but it probably can be done. Thanks!Posted the answer with the solution for the Run as admin. Hope this helps ! – Ob1lan – 2017-01-12T07:45:19.417