Skip to content

Instantly share code, notes, and snippets.

@techdecline
Created September 20, 2018 13:45
Show Gist options
  • Select an option

  • Save techdecline/5d938625c4a2dd6e0925f22c5b2364b8 to your computer and use it in GitHub Desktop.

Select an option

Save techdecline/5d938625c4a2dd6e0925f22c5b2364b8 to your computer and use it in GitHub Desktop.
Resolve Shell Folder
function Resolve-UWMShellFolder {
[CmdletBinding()]
param (
# Shell Folder Name
[Parameter(Mandatory,ValueFromPipeline)]
[string]
$ShellFolderName
)
process {
$shellFolderArr = [Environment+SpecialFolder]::GetNames([Environment+SpecialFolder])
if ($shellFolderArr -contains $ShellFolderName ) {
$shellFolderPath = [System.Environment]::GetFolderPath("$ShellFolderName")
return $shellFolderPath
}
elseif (([System.Environment]::GetEnvironmentVariables().getenumerator() | Select-Object -ExpandProperty Name) -contains $ShellFolderName) {
$shellFolderPath = [System.Environment]::GetEnvironmentVariable($ShellFolderName)
return $shellFolderPath
}
else {
return $null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment