List all
$knownFolders = Get-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
foreach ($folder in $knownFolders) {
$props = Get-ItemProperty $folder.PSPath
foreach ($p in $props.PSObject.Properties) {
Write-Host "$($p.Name) = $($p.Value)"
}
}
Replace all based on a condition
$knownFolders = Get-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
foreach ($folder in $knownFolders) {
$props = Get-ItemProperty $folder.PSPath
foreach ($p in $props.PSObject.Properties) {
if ($p.Value -like "C:\Users\Administrator\*") {
$newValue = $($p.Value).Replace('C:\Users\Administrator\', 'X:\Data\Administrator\')
Set-ItemProperty -Path $props.PSPath -Name $p.Name -Value $newValue
# Get-ItemProperty -Path $props.PSPath -Name $p.Name
}
}
}
Note: this is highly not recommended approach, there is only one valid approach - sysprep