How can I use nested ForEach-Object? The $_ is returns "HKCU:.." but I want to access "Microsoft Teams" string inside second ForEach-Object.
@(
"Microsoft Teams",
"Microsoft Teams Meeting Add-in for Microsoft Office",
"Teams Machine-Wide Installer"
) | ForEach-Object {
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | ForEach-Object {
Write-Host $_
}
}
The $_ of the first
ForEach-Objectneeds to be saved into a variable. Then, used inside the secondForEach-Object.