문제

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