PowerShell USMT错误26即使在管理员帐户下也无法访问Windows文件

时间:2019-05-26 11:25:22

标签: windows powershell data-migration

我正在尝试使用usmt进行备份并编写简单的脚本来处理它,问题是当我在外部域设备上工作时,它工作得很好,现在当使用活动目录时,似乎无法即使使用管理员帐户也可以访问Windows文件。

让它以admin身份运行的第一行,并且我使用的是在这台PC上具有admin特权的用户,所以我无法完全解决问题所在

    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)

日志文件

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] +-----------------------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

要解决某个问题,您必须拥有不那么简单的事情,因此告诉老板,他可以为您提供所需的东西,或者他可以自己完成。

  

您必须使用具有完全管理权限的帐户运行USMT   权限,包括以下特权:

     

SeBackupPrivilege(备份文件和目录)

     

SeDebugPrivilege(调试程序)

     

SeRestorePrivilege(还原文件和目录)

     

SeSecurityPrivilege(管理审核和安全日志)

     

SeTakeOwnership特权(获取文件或其他对象的所有权)

来源: https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-requirements