Skip to content

Instantly share code, notes, and snippets.

@Hexalon
Last active June 10, 2016 19:05
Show Gist options
  • Save Hexalon/c8fbf69e7545f2a13a1caf57e1cddf3d to your computer and use it in GitHub Desktop.
Save Hexalon/c8fbf69e7545f2a13a1caf57e1cddf3d to your computer and use it in GitHub Desktop.
Queries redirected folder locations using the .NET Framework. Stores data in an ordered hash table and writes to the pipline.
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.122
Created on: 5/31/2016 15:00
Created by: Colin Squier <[email protected]
Filename: CheckFolderRedirection.ps1
===========================================================================
.DESCRIPTION
Queries redirected folder locations using the .NET Framework. Stores
data in an ordered hash table and writes to the pipeline.
#>
[CmdletBinding()]
Param ()
function Get-FolderLocations
{
$RedirectedFolders = @()
$Props = [ordered]@{
'Computer' = $env:COMPUTERNAME
'UserName' = $env:USERNAME
'AppData' = ([System.Environment]::GetFolderPath("ApplicationData"))
'Desktop' = ([System.Environment]::GetFolderPath("Desktop"))
'Documents' = ([System.Environment]::GetFolderPath("MyDocuments"))
'Favorites' = ([System.Environment]::GetFolderPath("Favorites"))
'StartMenu' = ([System.Environment]::GetFolderPath("StartMenu"))
}
$RedirectedFolders += New-Object -TypeName PSObject -Property $Props
Write-Output $RedirectedFolders
}
$FolderLocations = Get-FolderLocations
$FolderLocations = ($FolderLocations | Out-String).Trim()
Write-Output $FolderLocations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment