List redirected user folders

For the selected user session/s, enumerates all user shell folders redirected to a non-default location outside the user profile.

Version: 4.1.8
Created: 2014-06-23T13:18:36.533
Modified: 2016-06-15T16:42:39.623
Creator: Zeev Eisenberg
Downloads: 675
Tags:
The Script Copy Script Copied to clipboard

Function Get-RegistryKeyPropertiesAndValues
{
<# This function is used here to retrieve registry values while omitting the PS properties Example: Get-RegistryKeyPropertiesAndValues -path 'HKCU:Volatile Environment' Origin: Http://www.ScriptingGuys.com/blog Via: http://stackoverflow.com/questions/13350577/can-powershell-get-childproperty-get-a-list-of-real-registry-keys-like-reg-query #>

Param(
[Parameter(Mandatory=$true)]
[string]$path
)

Push-Location
Set-Location -Path $path
Get-Item . |
Select-Object -ExpandProperty property |
ForEach-Object {
New-Object psobject -Property @{“Folder”=$_;
“RedirectedLocation” = (Get-ItemProperty -Path . -Name $_).$_}}
Pop-Location
}

# Get the user profile path, while escaping special characters because we are going to use the -match operator on it
$Profilepath = [regex]::Escape($env:USERPROFILE)

# List all folders
$RedirectedFolders = Get-RegistryKeyPropertiesAndValues -Path “HKCU:SoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders” | Where-Object {$_.RedirectedLocation -notmatch “$Profilepath”}
if ($RedirectedFolders -eq $null) {
Write-Output “No folders are redirected for this user”
} else {
$RedirectedFolders | format-list *
}

START YOUR TRIAL

Get Your Download Link

Gain access to ControlUp from your PC. Register and get a link to start your Free Trial.