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

How to Add Windows Administrative Templates to Domain Group Policies

Three Quick Steps to Adding ADMX Administrative templates are the blue prints of Windows machines.…

Toner Cartridge CF283A vs CF283X

These toners will work with HP Pro MFP M127fw M127fn M125nw M201dw M201n M225dn M225dw…

Linux: Remediate SSL Weak Cipher Suites

Description The remote host supports the use of SSL ciphers that offer weak encryption. Note:…