Skip to content

Instantly share code, notes, and snippets.

@DeploymentMX
Created October 30, 2019 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeploymentMX/d77764f8be0597100b472d96e91060e6 to your computer and use it in GitHub Desktop.
Save DeploymentMX/d77764f8be0597100b472d96e91060e6 to your computer and use it in GitHub Desktop.
Write-Host "
##########################################################################
# *** User State Migration Script *** #
# ====================================================================== #
# #
# Select a option bellow: #
# [1] Run Backup of User State (ScanState) #
# [2] Run Restore of User State (LoadState) #
# [3] Exit Script #
# #
##########################################################################
" -ForegroundColor Yellow
$Drive_Letters = (get-location).Drive.Name
<#Write-Host = "Change Driver Letter" "$Drive_Letters" -ForegroundColor Red#>
$Option = Read-Host "Select Option: [1][2][3]"
switch ($Option)
{
1 {
$USMTFilePath = Read-Host "Retype this files USMT link "$Drive_Letters":\guardadatos$\USMT\"
$MigDataPath = Read-Host "Retype this Destination link "$Drive_Letters":\guardadatos$\MigData\$env:computername\"
$USMTTmp = New-Item -Path "C:\USMTTemp" -ItemType Directory -Force
Write-Host "Copy USMT tools..."
Start-Sleep 3
robocopy "$USMTFilePath" "$USMTTmp" /MIR
Write-Host "scanstate working..."
Set-Location "$USMTTmp"
.\scanstate.exe $MigDataPath /i:MigApp.xml /i:MigDocs.xml /v:13 /o /c /nocompress
Start-Sleep 10
Write-Host "Removing USMT Temp Folder"
Remove-Item -Path $USMTTmp -Recurse -Force
}
2 {
$USMTFilePath = Read-Host "Retype this files USMT link "$Drive_Letters":\\guardadatos$\USMT\"
$MigDataPath = Read-Host "Retype this Destination link "$Drive_Letters":\guardadatos$\MigData\$env:computername\"
$USMTTmp = New-Item -Path "C:\USMTTemp" -ItemType Directory -Force
Write-Host "Copy USMT tools..."
Start-Sleep 3
robocopy "$USMTFilePath" "$USMTTmp" /MIR
Write-Host "loadstate working..."
Set-Location "$USMTTmp"
.\loadstate.exe "$MigDataPath" /lac /lae /i:MigApp.xml /i:MigDocs.xml /v:13 /c /nocompress
Start-Sleep 10
Write-Host "Removing USMT Temp Folder"
Remove-Item -Path $USMTTmp -Recurse -Force
}
default {
Write-Host 'Exinting Script, wait...'
Start-Sleep 4
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment