I am stuck at how to actually find the parent folder to add a new registry key using powershell. The reason is because the device shows as a different value per computer. And the registry that I am trying to add will set the default over to the "internal mic"'s parents key. Here is the code

    $pathToIntMic = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture | Where-Object { .Name -eq "internal mic"}
    #$intMicParent = (Get-item $pathToIntMic).parent.Fullname
    #write-host $intMicParent

The last two line are commented out but serve just to get the parent folder key name just under \Audio\Capture.

Thanks for any help!

没有正确的解决方案

其他提示

Use the property PSParentPath:

$key = 'SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture'
$pathToIntMic = Get-ItemProperty "HKLM:\$key" | ? { $_.Name -eq "internal mic" }
Write-Host $pathToIntMic.PSParentPath

You can enumerate the properties and methods of an object by piping it into the Get-Member cmdlet:

$pathToIntMic | Get-Member
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top