Created
February 28, 2026 09:23
-
-
Save idiotandrobot/0ad9159dd8ae938f3f5d1e7de112d9f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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-DownloadFolderPath() { | |
| $SHGetKnownFolderPathSignature = @' | |
| [DllImport("shell32.dll", CharSet = CharSet.Unicode)] | |
| public extern static int SHGetKnownFolderPath( | |
| ref Guid folderId, | |
| uint flags, | |
| IntPtr token, | |
| out IntPtr lpszProfilePath); | |
| '@ | |
| $GetKnownFoldersType = Add-Type -MemberDefinition $SHGetKnownFolderPathSignature -Name 'GetKnownFolders' -Namespace 'SHGetKnownFolderPath' -Using "System.Text" -PassThru | |
| $folderNameptr = [intptr]::Zero | |
| [void]$GetKnownFoldersType::SHGetKnownFolderPath([Ref]"374DE290-123F-4565-9164-39C4925E467B", 0, 0, [ref]$folderNameptr) | |
| $folderName = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($folderNameptr) | |
| [System.Runtime.InteropServices.Marshal]::FreeCoTaskMem($folderNameptr) | |
| $folderName | |
| } | |
| Export-ModuleMember -Function Get-DownloadFolderPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment