I am trying to make backup using usmt
and making simple script to handle it, the problem is when I was working from outside domain device it worked just fine, now when using active directory it seems to not be able to access windows files even with an admin account.
the first line for getting it to run as admin, and I am using the user which has admin privileges on this pc, so I can't wrap my head what the issue is
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
Set-ExecutionPolicy Bypass
Do {
$whichState = Read-Host -Prompt 'Do you want to Backup Or Restore for Backup Enter "B" and for Restore Enter "R"'
if ($whichState -eq "b" ) {
# $preUsbLetter = Read-Host -Prompt 'Enter Usb Letter'
$preUsbLetter = 'a'
if ($preUsbLetter.length -eq 1 ) {
$testBackup = '\\12.34.56.789\softwares\TestBackup'
# $usbLetter = $preusbLetter + ":\usmt"
$usbLetter = $testBackup + "\usmt"
$employeeNumber = Read-Host -Prompt 'Enter your employee Number'
$backupFolder = "\USER#" + $employeeNumber
# $backupPath = $usbLetter + '\backup' + $backupFolder
$backupPath = $testBackup + $backupFolder
Write-Host "usb path is $usbLetter and user number is $employeeNumber and backup bath is $backupPath "
$Activ = 'Backup'
$stat = 'userData Backing up'
Write-Progress -Activity $Activ -Status $stat -PercentComplete 25
Set-Location $usbLetter
SkipUserData=No
.\scanstate $backupPath /o /c /i:MigUser.xml /i:MigDocs.xml /i:MigApp.xml /localonly
Read-Host -Prompt "DONE press Enter To exit"
break
}
else {
write-host "-------------------------------"
write-host "Wrong Input"
write-host "-------------------------------"
}
}
elseif ($whichState -eq "r") {
$preUsbLetter = Read-Host -Prompt 'Enter Usb Letter'
if ($preUsbLetter.length -eq 1 ) {
# $usbLetter = $preusbLetter + ":\usmt"
$usbLetter = $testBackup + "\usmt"
$testBackup = '\\12.34.56.789\softwares\TestBackup'
$employeeNumber = Read-Host -Prompt 'Enter your employee Number'
$backupFolder = "\USER#" + $employeeNumber
# $backupPath = $usbLetter + '\backup\' + $backupFolder
$backupPath = $testBackup + $backupFolder
Write-Host "usb path is $usbLetter and user number is $employeeNumber and backup bath is $backupPath "
$Activ = 'Restore'
$stat = 'Restoring UserData'
Write-Progress -Activity $Activ -Status $stat -PercentComplete 25
Set-Location $usbLetter
.\loadstate /i:MigApp.xml /i:MigUser.xml /i:MigDocs.xml $backupPath /all /lac: P@ssw0rd /lae /c
Read-Host -Prompt "DONE press Enter To exit"
break
}
else {
write-host "-------------------------------"
write-host "Wrong Input"
write-host "-------------------------------"
}
}
else {
write-host "-------------------------------"
write-host "Wrong Input"
write-host "-------------------------------"
}
}while ($true)
the log file
2019-05-26 10:28:07, Info [0x000000] SCANSTATE.EXE[gle=0x000000b7]
2019-05-26 10:28:07, Info [0x000000] USMT Started at 2019/05/26:10:28:07.821
2019-05-26 10:28:07, Info [0x000000] Command line: \\12.34.56.789\softwares\TestBackup\USMT\scanstate.exe \\12.34.56.789\softwares\TestBackup\USER#111 /o /c /i:MigUser.xml /i:MigDocs.xml /i:MigApp.xml /localonly
2019-05-26 10:28:07, Info [0x000000] Starting the migration process
2019-05-26 10:28:07, Warning [0x080405] AdjustPrivilege: AdjustTokenPrivileges failed (Error:0x514)
2019-05-26 10:28:07, Warning [0x080405] AdjustPrivilege: AdjustTokenPrivileges failed (Error:0x514)
2019-05-26 10:28:07, Warning [0x080405] AdjustPrivilege: AdjustTokenPrivileges failed (Error:0x514)
2019-05-26 10:28:07, Warning [0x080405] AdjustPrivilege: AdjustTokenPrivileges failed (Error:0x514)
2019-05-26 10:28:07, Warning [0x080405] AdjustPrivilege: AdjustTokenPrivileges failed (Error:0x514)
2019-05-26 10:28:07, Error [0x018000] 00000001 (F) HRESULT_FROM_WIN32(1300) #1# from LoadStore(target = NULL)
[gle=0x80004005]
2019-05-26 10:28:07, Warning [0x08040d] SMI engine was unable to load store (hr = 0x80070514)
2019-05-26 10:28:07, Warning [0x0803d9] IndirectKeyMapper: RegLoadKey(HKEY_LOCAL_MACHINE,$ONLINE_RW$ELAM,C:\windows\system32\config\elam) failed (1314)
2019-05-26 10:28:07, Warning [0x0803db] IndirectKeyMapper: RegLoadKey(HKEY_LOCAL_MACHINE,$ONLINE_RW$ELAM,C:\windows\system32\config\elam) failed; giving up (1314)
2019-05-26 10:28:07, Error [0x080000] Error loading hive C:\windows\system32\config\elam.: Win32Exception: A required privilege is not held by the client. [0x00000522] __cdecl Mig::CIndirectKeyMapper::CIndirectKeyMapper(class UnBCL::String *,struct HKEY__ *,class UnBCL::String *,class UnBCL::String *,int,int,const Mig::HiveLoadRetryOptions *)[gle=0x000000cb]
2019-05-26 10:28:08, Warning [0x0803d9] IndirectKeyMapper: RegLoadKey(HKEY_USERS,S-1-5-21-1455383882-3198487947-3576469728-1162,C:\Users\backup\NTUSER.DAT) failed (1314)
2019-05-26 10:28:08, Warning [0x0803db] IndirectKeyMapper: RegLoadKey(HKEY_USERS,S-1-5-21-1455383882-3198487947-3576469728-1162,C:\Users\backup\NTUSER.DAT) failed; giving up (1314)
2019-05-26 10:28:08, Error [0x08039d] Cannot add mapping for user profile C:\Users\backup. Error: 1314: Win32Exception: A required privilege is not held by the client. [0x00000522] __cdecl Mig::CIndirectKeyMapper::CIndirectKeyMapper(class UnBCL::String *,struct HKEY__ *,class UnBCL::String *,class UnBCL::String *,int,int,const Mig::HiveLoadRetryOptions *)[gle=0x000000cb]
2019-05-26 10:28:08, Error [0x080801] User profile loading error. Aborting due to external request.[gle=0x000000cb]
2019-05-26 10:28:08, Error [0x000000] MigPlatformStartupOnline caught exception: Win32Exception: User profile loading error. Aborting due to external request.: The specified user does not have a valid profile. [0x000004E5] void __cdecl Mig::COnlineWinNTPlatform::ProcessUser(class Mig::CRegistryDataStore *,class Mig::CRegistryDataUnit *,class UnBCL::String *,class UnBCL::String *,int,int)
2019-05-26 10:28:08, Error [0x000000] Error while trying to start the migration process
2019-05-26 10:28:08, Warning [0x000000] Internal error 4 was translated to a generic error
2019-05-26 10:28:08, Info [0x000000] Failed.
2019-05-26 10:28:08, Info [0x000000] Software malfunction or Unknown exception
2019-05-26 10:28:08, Info [0x000000] USMT Completed at 2019/05/26:10:28:08.008
2019-05-26 10:28:08, Info [0x000000] ----------------------------------- USMT ERROR SUMMARY -----------------------------------
2019-05-26 10:28:08, Info [0x000000] * USMT error code 26:
2019-05-26 10:28:08, Info [0x000000] +-----------------------------------------------------------------------------------------
2019-05-26 10:28:08, Info [0x000000] | Software malfunction or Unknown exception, please check the following possible solutions:
2019-05-26 10:28:08, Info [0x000000] | - Check log for any errors found in loaded migxml files
2019-05-26 10:28:08, Info [0x000000] | - Verify config xml file is not loaded using /i
2019-05-26 10:28:08, Info [0x000000] | - If duplicate SID exists from temp profile – use environment variable or delete temp profile
2019-05-26 10:28:08, Info [0x000000] +-----------------------------------------------------------------------------------------
To fix something you have to have access to things you don't have as simple as that so tell your boss he can get you what you need or he can do it himself.
You must run USMT using an account with full administrative permissions, including the following privileges:
SeBackupPrivilege (Back up files and directories)
SeDebugPrivilege(Debug programs)
SeRestorePrivilege (Restore files and directories)
SeSecurityPrivilege (Manage auditing and security log)
SeTakeOwnership Privilege (Take ownership of files or other objects)
Source: https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-requirements
User contributions licensed under CC BY-SA 3.0