Вы находитесь на странице: 1из 3

##### User profile Backup & Restore (For machine swaps)

##### https://community.spiceworks.com/scripts/show_download/2640-user-profile-
backup-restore-for-machine-swaps

$destination = "\\SERVER\Share\backups"

$folder = "Desktop",
"Downloads",
"Favorites",
"Documents",
"Music",
"Pictures",
"Videos",
"AppData\Local\Mozilla",
"AppData\Local\Google",
"AppData\Roaming\Mozilla"

###################################################################################
############################

$username = gc env:username
$userprofile = gc env:userprofile
$appData = gc env:localAPPDATA

###### Restore data section ######


if ([IO.Directory]::Exists($destination + "\" + $username + "\"))
{

$caption = "Choose Action";


$message = "A backup folder for $username already exists, would you like to
restore the data to the local machine?";
$Yes = new-Object System.Management.Automation.Host.ChoiceDescription
"&Yes","Yes";
$No = new-Object System.Management.Automation.Host.ChoiceDescription
"&No","No";
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes,$No);
$answer = $host.ui.PromptForChoice($caption,$message,$choices,0)

if ($answer -eq 0)
{

write-host -ForegroundColor green "Restoring data to local machine for


$username"
foreach ($f in $folder)
{
$currentLocalFolder = $userprofile + "\" + $f
$currentRemoteFolder = $destination + "\" + $username + "\" + $f
write-host -ForegroundColor cyan " $f..."
Copy-Item -ErrorAction silentlyContinue -recurse
$currentRemoteFolder $userprofile

if ($f -eq "AppData\Local\Mozilla") { rename-item


$currentLocalFolder "$currentLocalFolder.old" }
if ($f -eq "AppData\Roaming\Mozilla") { rename-item
$currentLocalFolder "$currentLocalFolder.old" }
if ($f -eq "AppData\Local\Google") { rename-item
$currentLocalFolder "$currentLocalFolder.old" }
}
rename-item "$destination\$username" "$destination\$username.restored"
write-host -ForegroundColor green "Restore Complete!"
}

else
{
write-host -ForegroundColor yellow "Aborting process"
exit
}

###### Backup Data section ########


else
{

Write-Host -ForegroundColor green "Outlook is about to close, save any


unsaved emails then press any key to continue ..."

$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Get-Process | Where { $_.Name -Eq "OUTLOOK" } | Kill

write-host -ForegroundColor green "Backing up data from local machine for


$username"

foreach ($f in $folder)


{
$currentLocalFolder = $userprofile + "\" + $f
$currentRemoteFolder = $destination + "\" + $username + "\" + $f
$currentFolderSize = (Get-ChildItem -ErrorAction silentlyContinue
$currentLocalFolder -Recurse -Force | Measure-Object -ErrorAction silentlyContinue
-Property Length -Sum ).Sum / 1MB
$currentFolderSizeRounded = [System.Math]::Round($currentFolderSize)
write-host -ForegroundColor cyan " $f... ($currentFolderSizeRounded
MB)"
Copy-Item -ErrorAction silentlyContinue -recurse $currentLocalFolder
$currentRemoteFolder
}

$oldStylePST = [IO.Directory]::GetFiles($appData + "\Microsoft\Outlook",


"*.pst")
foreach($pst in $oldStylePST)
{
if ((test-path -path ($destination + "\" + $username +
"\Documents\Outlook Files\oldstyle")) -eq 0){new-item -type directory -path
($destination + "\" + $username + "\Documents\Outlook Files\oldstyle") | out-null}
write-host -ForegroundColor yellow " $pst..."
Copy-Item $pst ($destination + "\" + $username + "\Documents\Outlook
Files\oldstyle")
}

write-host -ForegroundColor green "Backup complete!"

Вам также может понравиться

  • Malware Alert - Uninstall Command Found in Downloads
    Malware Alert - Uninstall Command Found in Downloads
    Документ6 страниц
    Malware Alert - Uninstall Command Found in Downloads
    mark skkin
    Оценок пока нет
  • !FixAlign Test 6.Sh
    !FixAlign Test 6.Sh
    Документ6 страниц
    !FixAlign Test 6.Sh
    Zoelfikar Genex
    Оценок пока нет
  • Webshell PHP JPG
    Webshell PHP JPG
    Документ3 страницы
    Webshell PHP JPG
    Quratulain Tariq
    Оценок пока нет
  • AddOracleDbToOracleClusterGroup ps1
    AddOracleDbToOracleClusterGroup ps1
    Документ5 страниц
    AddOracleDbToOracleClusterGroup ps1
    Lo Mejor Medellin
    Оценок пока нет
  • App Install Script
    App Install Script
    Документ8 страниц
    App Install Script
    Remus Tucker
    Оценок пока нет
  • Rsync Automatic Backup Script - RHEL5
    Rsync Automatic Backup Script - RHEL5
    Документ3 страницы
    Rsync Automatic Backup Script - RHEL5
    Piyush Sachan
    Оценок пока нет
  • Pesan 3296
    Pesan 3296
    Документ128 страниц
    Pesan 3296
    Achmad Yusuf
    Оценок пока нет
  • K 3 B6 XJ EF
    K 3 B6 XJ EF
    Документ58 страниц
    K 3 B6 XJ EF
    Eiman Dragon Uzmi
    Оценок пока нет
  • OS Lab
    OS Lab
    Документ9 страниц
    OS Lab
    Ab Gani Mia
    Оценок пока нет
  • Mecw
    Mecw
    Документ58 страниц
    Mecw
    Candace Prince
    Оценок пока нет
  • Pizza PHP
    Pizza PHP
    Документ8 страниц
    Pizza PHP
    Anonymous pYFRT2Zxg
    Оценок пока нет
  • Legato Scripting Document
    Legato Scripting Document
    Документ26 страниц
    Legato Scripting Document
    vikisorte
    Оценок пока нет
  • Restore 11g Homes
    Restore 11g Homes
    Документ8 страниц
    Restore 11g Homes
    Saeed Meethal
    Оценок пока нет
  • Lab 3 OSG
    Lab 3 OSG
    Документ9 страниц
    Lab 3 OSG
    dangphhe172554
    Оценок пока нет
  • Dbsender
    Dbsender
    Документ3 страницы
    Dbsender
    sherif
    Оценок пока нет
  • Audit
    Audit
    Документ7 страниц
    Audit
    Андрей Миксонов
    Оценок пока нет
  • Imply
    Imply
    Документ17 страниц
    Imply
    SandraPerera
    Оценок пока нет
  • Dhanvanthari Homa Sm3
    Dhanvanthari Homa Sm3
    Документ9 страниц
    Dhanvanthari Homa Sm3
    Vemuganti Sudhakar
    Оценок пока нет
  • Unifi SH Api
    Unifi SH Api
    Документ4 страницы
    Unifi SH Api
    Maluco Beleza
    Оценок пока нет
  • Make File
    Make File
    Документ2 страницы
    Make File
    Srikanta21
    Оценок пока нет
  • Kernel CK Ubuntu
    Kernel CK Ubuntu
    Документ7 страниц
    Kernel CK Ubuntu
    ravenkill
    Оценок пока нет
  • Ke Mend Agri
    Ke Mend Agri
    Документ15 страниц
    Ke Mend Agri
    Luar Negeri
    Оценок пока нет
  • A TCL Script For An Ns-2 Wireless Simulation, That Uses A Single Broadcast Traffic Class.
    A TCL Script For An Ns-2 Wireless Simulation, That Uses A Single Broadcast Traffic Class.
    Документ3 страницы
    A TCL Script For An Ns-2 Wireless Simulation, That Uses A Single Broadcast Traffic Class.
    itsme_mrsatya
    Оценок пока нет
  • Util Functions
    Util Functions
    Документ13 страниц
    Util Functions
    lord.blessed001
    Оценок пока нет
  • RegisterBackup ps1
    RegisterBackup ps1
    Документ2 страницы
    RegisterBackup ps1
    D. D.
    Оценок пока нет
  • Adrci Purge
    Adrci Purge
    Документ3 страницы
    Adrci Purge
    Jennifer Norris
    Оценок пока нет
  • Collect SH
    Collect SH
    Документ19 страниц
    Collect SH
    Dinesh Goyal
    Оценок пока нет
  • Final PHP Code
    Final PHP Code
    Документ16 страниц
    Final PHP Code
    aabapurbo2083
    Оценок пока нет
  • HTML ($file)
    HTML ($file)
    Документ8 страниц
    HTML ($file)
    anon-713221
    Оценок пока нет
  • Shell
    Shell
    Документ42 страницы
    Shell
    Naise Try
    Оценок пока нет
  • Arduino Installation Commands
    Arduino Installation Commands
    Документ8 страниц
    Arduino Installation Commands
    Arun Kumar
    Оценок пока нет
  • PS Delete TEMP Logon User
    PS Delete TEMP Logon User
    Документ2 страницы
    PS Delete TEMP Logon User
    Thio Lutfi Habibi
    Оценок пока нет
  • Have A Profile Picture
    Have A Profile Picture
    Документ3 страницы
    Have A Profile Picture
    Chief Mack
    Оценок пока нет
  • Uhttpd
    Uhttpd
    Документ3 страницы
    Uhttpd
    sasaiama
    Оценок пока нет
  • Zmbkpose Install
    Zmbkpose Install
    Документ3 страницы
    Zmbkpose Install
    jetbards
    Оценок пока нет
  • Install Dcm4chee5
    Install Dcm4chee5
    Документ10 страниц
    Install Dcm4chee5
    crisnole7
    Оценок пока нет
  • Eagle Shell - Based On 1n73ction
    Eagle Shell - Based On 1n73ction
    Документ124 страницы
    Eagle Shell - Based On 1n73ction
    Igor Eduardo
    Оценок пока нет
  • IRC Bot v2.2
    IRC Bot v2.2
    Документ7 страниц
    IRC Bot v2.2
    Frank
    Оценок пока нет
  • Thug
    Thug
    Документ11 страниц
    Thug
    moramora12
    100% (1)
  • PHP
    PHP
    Документ56 страниц
    PHP
    methodeirambona180
    Оценок пока нет
  • Kalinethunter
    Kalinethunter
    Документ4 страницы
    Kalinethunter
    Estorno Estorno
    Оценок пока нет
  • Firebird
    Firebird
    Документ9 страниц
    Firebird
    Pumitas Kamy
    Оценок пока нет
  • STD Out
    STD Out
    Документ12 страниц
    STD Out
    peter
    Оценок пока нет
  • Kali Linux
    Kali Linux
    Документ9 страниц
    Kali Linux
    rasak jr
    Оценок пока нет
  • Scriptsal
    Scriptsal
    Документ4 страницы
    Scriptsal
    Sal N
    Оценок пока нет
  • Unix Shell Scripts
    Unix Shell Scripts
    Документ57 страниц
    Unix Shell Scripts
    Manik Basha
    Оценок пока нет
  • Traceback
    Traceback
    Документ3 страницы
    Traceback
    Cap
    Оценок пока нет
  • Name-Muskan Agarwal Assignment-1 Codingclub
    Name-Muskan Agarwal Assignment-1 Codingclub
    Документ7 страниц
    Name-Muskan Agarwal Assignment-1 Codingclub
    Muskan Agarwal
    Оценок пока нет
  • OS Assignment-02
    OS Assignment-02
    Документ9 страниц
    OS Assignment-02
    780ANAY GUPTA
    Оценок пока нет
  • Traceback
    Traceback
    Документ3 страницы
    Traceback
    Diego Laura
    Оценок пока нет
  • Fey N Install
    Fey N Install
    Документ4 страницы
    Fey N Install
    Mateo Andres Duran Barraza
    Оценок пока нет
  • Mini Shell
    Mini Shell
    Документ9 страниц
    Mini Shell
    james
    Оценок пока нет
  • Phpbuka Vba
    Phpbuka Vba
    Документ8 страниц
    Phpbuka Vba
    Joe Habybie
    Оценок пока нет
  • PHP Stringovi Nizovi
    PHP Stringovi Nizovi
    Документ18 страниц
    PHP Stringovi Nizovi
    Loris Kope
    Оценок пока нет
  • Websyk
    Websyk
    Документ33 страницы
    Websyk
    Anonymous hA4Erb
    Оценок пока нет
  • Solaris10 Monitoring Script
    Solaris10 Monitoring Script
    Документ9 страниц
    Solaris10 Monitoring Script
    rittal
    Оценок пока нет
  • Rad2f5 TMSH
    Rad2f5 TMSH
    Документ8 страниц
    Rad2f5 TMSH
    Harry Sh
    Оценок пока нет
  • c99 PHP
    c99 PHP
    Документ71 страница
    c99 PHP
    egyhacker
    Оценок пока нет
  • How to a Developers Guide to 4k: Developer edition, #3
    How to a Developers Guide to 4k: Developer edition, #3
    От Everand
    How to a Developers Guide to 4k: Developer edition, #3
    Оценок пока нет
  • Bash Command Line Pro Tips
    Bash Command Line Pro Tips
    От Everand
    Bash Command Line Pro Tips
    Рейтинг: 4.5 из 5 звезд
    4.5/5 (8)
  • Overview of Risk Based Audit Process
    Overview of Risk Based Audit Process
    Документ17 страниц
    Overview of Risk Based Audit Process
    Aira Nhaira Mecate
    100% (1)
  • Renaissance Questions
    Renaissance Questions
    Документ3 страницы
    Renaissance Questions
    Hezel Escora Navales
    Оценок пока нет
  • Getting Started in Steady State
    Getting Started in Steady State
    Документ24 страницы
    Getting Started in Steady State
    amit
    Оценок пока нет
  • 33392-01 Finegayan Water Tank KORANDO PDF
    33392-01 Finegayan Water Tank KORANDO PDF
    Документ3 страницы
    33392-01 Finegayan Water Tank KORANDO PDF
    Shady Rain
    Оценок пока нет
  • API RP 1102 Spreadsheet
    API RP 1102 Spreadsheet
    Документ5 страниц
    API RP 1102 Spreadsheet
    drramsay
    100% (4)
  • Labnet MultiGene Manual PDF
    Labnet MultiGene Manual PDF
    Документ42 страницы
    Labnet MultiGene Manual PDF
    cuma mencoba
    Оценок пока нет
  • Jastram Rudder Feedback Unit
    Jastram Rudder Feedback Unit
    Документ21 страница
    Jastram Rudder Feedback Unit
    Gary Gouveia
    100% (3)
  • April 7-9 2022-WPS Office
    April 7-9 2022-WPS Office
    Документ3 страницы
    April 7-9 2022-WPS Office
    Allen Antolin
    Оценок пока нет
  • Chapter 5 Assessment, Solution Manual, Electrons in Atoms, Glencoe, Chemistry
    Chapter 5 Assessment, Solution Manual, Electrons in Atoms, Glencoe, Chemistry
    Документ9 страниц
    Chapter 5 Assessment, Solution Manual, Electrons in Atoms, Glencoe, Chemistry
    pumeananda
    100% (3)
  • Snap-Tite75 Series-Catalog 3800 - SectionB
    Snap-Tite75 Series-Catalog 3800 - SectionB
    Документ3 страницы
    Snap-Tite75 Series-Catalog 3800 - SectionB
    francis_15in
    Оценок пока нет
  • BP KWN RPM W KGW KGW KGW KG SFC GM KWHR Caloricfivalue MJ KG
    BP KWN RPM W KGW KGW KGW KG SFC GM KWHR Caloricfivalue MJ KG
    Документ3 страницы
    BP KWN RPM W KGW KGW KGW KG SFC GM KWHR Caloricfivalue MJ KG
    Hoàng Khôi
    100% (1)
  • Problems 1
    Problems 1
    Документ2 страницы
    Problems 1
    Andoy Don M.
    Оценок пока нет
  • 2022 05 141RBSF351652506386
    2022 05 141RBSF351652506386
    Документ6 страниц
    2022 05 141RBSF351652506386
    tathagat jha
    Оценок пока нет
  • Tank Top Return Line Filter Pi 5000 Nominal Size 160 1000 According To Din 24550
    Tank Top Return Line Filter Pi 5000 Nominal Size 160 1000 According To Din 24550
    Документ8 страниц
    Tank Top Return Line Filter Pi 5000 Nominal Size 160 1000 According To Din 24550
    Mauricio Ariel H. Orellana
    Оценок пока нет
  • Traps
    Traps
    Документ11 страниц
    Traps
    Amandeep Arora
    Оценок пока нет
  • July 2014 GEARS
    July 2014 GEARS
    Документ76 страниц
    July 2014 GEARS
    Rodger Bland
    Оценок пока нет
  • Vocabulary: Activity 1
    Vocabulary: Activity 1
    Документ18 страниц
    Vocabulary: Activity 1
    Aurora Gonzalez
    Оценок пока нет
  • Hydrology: Dua'a Telfah PH.D, Civil Engineering Department Jadara University
    Hydrology: Dua'a Telfah PH.D, Civil Engineering Department Jadara University
    Документ104 страницы
    Hydrology: Dua'a Telfah PH.D, Civil Engineering Department Jadara University
    Faris Almomani
    Оценок пока нет
  • Catalog ITEM - Pdf4a3667894b315
    Catalog ITEM - Pdf4a3667894b315
    Документ552 страницы
    Catalog ITEM - Pdf4a3667894b315
    Domokos Levente
    Оценок пока нет
  • CS221 - Artificial Intelligence - Search - 4 Dynamic Programming
    CS221 - Artificial Intelligence - Search - 4 Dynamic Programming
    Документ23 страницы
    CS221 - Artificial Intelligence - Search - 4 Dynamic Programming
    Ardiansyah Mochamad Nugraha
    Оценок пока нет
  • Galaxy A8 User Manual
    Galaxy A8 User Manual
    Документ193 страницы
    Galaxy A8 User Manual
    Hüseyin ACAR
    Оценок пока нет
  • NAAC 10.12.1888888 New
    NAAC 10.12.1888888 New
    Документ48 страниц
    NAAC 10.12.1888888 New
    చిమ్ముల సందీప్ రెడ్డి
    Оценок пока нет
  • ZEOS-AS Manual
    ZEOS-AS Manual
    Документ2 страницы
    ZEOS-AS Manual
    rss1311
    Оценок пока нет
  • Additional Material On Communication
    Additional Material On Communication
    Документ15 страниц
    Additional Material On Communication
    Sasmita Nayak
    Оценок пока нет
  • 12V140 Seris Engine Shop Manual
    12V140 Seris Engine Shop Manual
    Документ471 страница
    12V140 Seris Engine Shop Manual
    Raed Mahyoub
    100% (4)
  • Executive Shirt Company
    Executive Shirt Company
    Документ6 страниц
    Executive Shirt Company
    Pramod k
    Оценок пока нет
  • Preview - ISO+8655 6 2022
    Preview - ISO+8655 6 2022
    Документ6 страниц
    Preview - ISO+8655 6 2022
    s7631040
    Оценок пока нет
  • (Dust of Snow) & 2 (Fire and Ice) - Notes
    (Dust of Snow) & 2 (Fire and Ice) - Notes
    Документ3 страницы
    (Dust of Snow) & 2 (Fire and Ice) - Notes
    daksh
    Оценок пока нет
  • L5CoachMentorReflectiveLog Template
    L5CoachMentorReflectiveLog Template
    Документ9 страниц
    L5CoachMentorReflectiveLog Template
    Hadusss
    Оценок пока нет
  • Amanuel Mekonnen
    Amanuel Mekonnen
    Документ125 страниц
    Amanuel Mekonnen
    abata yohannes
    Оценок пока нет