Question

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!

No correct solution

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top