Posted On September 28, 2021

Using SysPrep To Move Windows Users Directory

kimconnect 0 comments
blog.KimConnect.com >> Windows >> Using SysPrep To Move Windows Users Directory
Assumptions:
  1. Windows 2019 Server Standard ISO is mounted as E:\
  2. D:\Users will be the new location in lieu of C:\Users
  3. C:\ and D:\ are NTFS volumes
Preparation:
  1. Create a sysprep supplemental XML file as per the sample below
  2. Run sysprep.exe command

Contents of C:\unattend.xml

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="oobeSystem">
                <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                       <FolderLocations>
                              <ProfilesDirectory>D:\Users</ProfilesDirectory>
                      </FolderLocations>
               </component>
        </settings>
<cpi:offlineImage cpi:source="wim:E:/sources/install.wim#Windows Server 2019 Standard" xmlns:cpi="urn:schemas-microsoft-com:cpi" />

Run this command:

sysprep.exe /audit /reboot /unattend:C:\unattend.xml

The longer version of unattend.xml (for informational purposes)

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="specialize">
        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <RunSynchronous>
                <RunSynchronousCommand wcm:action="add">
                    <Description>Enable local administrator account</Description>
                    <Order>1</Order>
                    <Path>net user administrator /active:yes</Path>
                </RunSynchronousCommand>
            </RunSynchronous>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ComputerName></ComputerName>
            <CopyProfile>true</CopyProfile>
            <RegisteredOrganization>Dragon Coin LLC</RegisteredOrganization>
            <RegisteredOwner>Dragon Coin LLC</RegisteredOwner>
            <TimeZone>Pacific Standard Time</TimeZone>
        </component>
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UILanguageFallback>en-US</UILanguageFallback>
            <UserLocale>en-US</UserLocale>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <InputLocale>en-US</InputLocale>
            <SystemLocale>en-US</SystemLocale>
            <UILanguage>en-US</UILanguage>
            <UILanguageFallback>en-US</UILanguageFallback>
            <UserLocale>en-US</UserLocale>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                <NetworkLocation>Work</NetworkLocation>
                <ProtectYourPC>3</ProtectYourPC>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<SkipUserOOBE>true</SkipUserOOBE>
            </OOBE>
            <UserAccounts>
                <AdministratorPassword>
                    <Value>SOMECOMPLEXPASSWORDHERE!</Value>
                    <PlainText>false</PlainText>
                </AdministratorPassword>
            </UserAccounts>
            <RegisteredOrganization></RegisteredOrganization>
            <RegisteredOwner></RegisteredOwner>
            <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
            <TimeZone>Pacific Standard Time</TimeZone>
            <VisualEffects>
                <SystemDefaultBackgroundColor>2</SystemDefaultBackgroundColor>
            </VisualEffects>
        </component>
    </settings>
        <settings pass="oobeSystem">
                <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                       <FolderLocations>
                              <ProfilesDirectory>D:\Users</ProfilesDirectory>
                      </FolderLocations>
               </component>
        </settings>
    <cpi:offlineImage cpi:source="wim:e:/isos/windows2019Standard/install.wim#Windows Server 2019 Standard" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Use DISM To Install Windows Features

Deployment Image Servicing and Management (DISM.exe) is a command-line tool that can be used to…

PowerShell: Hyper-V Servers Capacity Report

Current Version: # HyperVCapacityReport.ps1 # Version 0.0.2 # Report parameters $workingDirectory='C:\scripts\googleSheets' $selectFields='node,model,os,cores,cpuUtilizationPercent,ramGb,ramUsedPercent' $domainObjects=@( @{domain='intranet.kimconnect.com';dc='lax-dc02.intranet.kimconnect.com';username='intranet\clusterReport';password=$env:clusterReportPass} @{domain='intranet.dragoncoin.com';dc='lax-dc02.intranet.dragoncoin.com';username='intranet\clusterReport';password=$env:clusterReportPass}…

Quick Notes of Beachy Systems Upgrade

Projects Proposal for Beachy Group (Fictional Entity)   Initial Fixed Costs Overview: SonicWall TZ215 $370…