none
Help with Powershell Script to Automate USMT

    Question

  • Hello,

    I'm currently trying to streamline USMT with the use PowerShell. I unfortunately cannot use MDT, WDS. or SCCM. I'm have a PowerShell script I worked on, but am in need of figuring out what I am missing to make it work. Hoping someone can help me get over that little bit.

    As the script stands now, I am getting an error shortly after I enter the Username of the person I want to have copied over. The way I have the script setup is to take parameters and insert those parameters into the arguments so I don't have to edit a .bat file for each new machine. I just want to be able to run this .ps1 from the Source machine and have it prompt me for variables. I want to run the equivalent using loadstate, which I will build as soon as I can figure out the scanstate.


    #
    # USMT_SCANSTATE.ps1
    #
    $Credentials = Get-Credential -Credential SmartDeployTest\
    $InvokingUser = $Credentials.UserName
    $ElevatedPassword = $Credentials.GetNetworkCredential().Password
    
    $SourcePCName = Read-Host -Prompt "Enter hostname of source PC"
    $CapturedUser = Read-Host -Prompt "Enter the username for the profile you want to capture"
    # must check for valid values
    
    $sb = {
    	Param(
    		$SourcePCName,
    		$CapturedUser
    	)
    	$scanstate = '\\smartdeploytest\USMT\amd64\scanstate.exe'
    	$arglist = @(
    		'/i:\\smartdeploytest\SAFE\$SourcePCName',
    		'/i:\\smartdeploytest\USMT\amd64\MigApp.xml',
    		'/i:\\smartdeploytest\USMT\amd64\MigDocs.xml',
    		'/i:\\smartdeploytest\USMT\amd64\Testxml.xml',
    		'/l:\\smartdeploytest\SAFE\$SourcePCNameSCANSTATE.log',
    		'/localonly',
    		'/o',
    		'/c',
    		'/vsc',
    		'/ue:*\*',
    		'/ui:example\$CapturedUser'
    	)
    	$process = Start-Process -FilePath $scanstate -ArgumentList $arglist -Wait -PassThru
    	# check process status
    }
    
    Invoke-Command $sb -ComputerName $SourcePCName -ArgumentList $SourcePCName,$CapturedUser
    
    Read-Host -Prompt "USMT-SAVESTATE Process has completed! Check USMT logs for details. (Press Enter to exit)"

    Wednesday, March 15, 2017 7:58 PM

All replies

  • Hi,

    From these error prompts to see, winrm configuration has to be checked on target computer.

    Please try this command to see if it helps:

    winrm set winrm/config/client @{TrustedHosts="RemoteComputerName"}

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, March 16, 2017 9:19 AM
    Moderator
  • Hi Kallb

    We have the same issue not using SCCM but we resorted to use User Profile Central - UPC from EhlerTech

     - The real beauty is that UPC does NOT use Powershell as we do not allow remote PS.

    1. UPC detects the users and list them,
    2. Runs USMT for you at the remote PC's
    3. and store the backups at/restore from/ a network share. 

    It even runs smoothly while the user is logged on. 

    UPC is REALLY simple to use and in the latest 1803 version comes with Customized XML files and even a fix for migration of Modern Apps like Sticky Notes and Edge Favorites.

    Regards
    Frank

    Tuesday, May 08, 2018 12:00 PM