Pergunta

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!

Nenhuma solução correta

Outras dicas

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top