Last active
March 7, 2024 20:04
-
-
Save MyITGuy/f0777b027a1d0254f08b96b80df38eae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-KNOWNFOLDERID { | |
<# | |
.SYNOPSIS | |
Lists KNOWNFOLDERID data. | |
.DESCRIPTION | |
Reads the registry and outputs a PSCustomObject and contains the KNOWNFOLDERID data. | |
.PARAMETER KNOWNFOLDERID | |
Limits the output to the provided KNOWNFOLDERID. | |
.OUTPUTS | |
PSCustomObject | |
.EXAMPLE | |
Get-KNOWNFOLDERID | |
Outputs all KNOWNFOLDERID data. | |
.EXAMPLE | |
Get-KNOWNFOLDERID -KNOWNFOLDERID '{F38BF404-1D43-42F2-9305-67DE0B28FC23}' | |
Outputs the KNOWNFOLDERID data for '{F38BF404-1D43-42F2-9305-67DE0B28FC23}'. | |
.NOTES | |
#> | |
[CmdletBinding()] | |
param ( | |
[string]$Id = '*' | |
) | |
$Path = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\$($Id)" | |
Get-ItemProperty -Path Registry::$Path | Sort-object -Property Name | ForEach-Object { | |
$Parent = $null | |
if ( $_.ParentFolder ) { | |
$Parent = Get-KNOWNFOLDERID -Id "$($_.ParentFolder)" | |
} | |
$Properties = [ordered]@{ | |
KNOWNFOLDERID = $_.PSChildName.ToUpper() | |
Name = $_.Name | |
ParentFolder = $_.ParentFolder | |
RelativePath = $_.RelativePath | |
Parent = $Parent | |
} | |
[PSCustomObject]$Properties | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment