<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Migrate Users Home Folder To A New File Server Using Powershell	</title>
	<atom:link href="https://thesysadminchannel.com/migrate-users-home-folder-new-file-server-using-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/migrate-users-home-folder-new-file-server-using-powershell/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Tue, 24 Oct 2023 21:12:26 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: Dennis		</title>
		<link>https://thesysadminchannel.com/migrate-users-home-folder-new-file-server-using-powershell/#comment-19794</link>

		<dc:creator><![CDATA[Dennis]]></dc:creator>
		<pubDate>Tue, 24 Oct 2023 21:12:26 +0000</pubDate>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=739#comment-19794</guid>

					<description><![CDATA[This is an enhanced script you can use with a TXT file. Just put the names line by line into the TXT file and run the script with your custom server names and domain name. Change the drive letter to one you like.

Import-Module ActiveDirectory
Import-Module NTFSSecurity

Function Migrate-UsersToNewHomeFolder {
    [CmdletBinding()]
    param(
        [string[]] $UserName,
        [string]   $OldServer = &#039;OldServerName&#039;,
        [string]   $NewServer = &#039;NewServerName&#039;,
        [string]   $Domain    = &#039;domain.com&#039;,
        [string]   $UserListFile
    )

    BEGIN {
        Import-Module ActiveDirectory
        Import-Module NTFSSecurity
    }

    PROCESS {
        if ($UserListFile -eq $null) {
            Write-Error &quot;Please provide a User file.&quot;
            return
        }

        $UserList = Get-Content $UserListFile

        foreach ($name in $UserList) {
            if ([bool](Get-ADUser -Filter {samaccountname -eq $name} )) {
                Get-ADUser $name &#124; Set-ADUser -HomeDrive H: -HomeDirectory &quot;\\$NewServer\Users\$name&quot;
                robocopy &quot;\\$OldServer\Users\$name&quot; &quot;\\$NewServer\Users\$name&quot; /mir /copy:datou /r:1 /w:10
                Start-Sleep -Seconds 2
                Set-NTFSOwner -Path &quot;\\$NewServer\Users\$name&quot; -Account Administrators
                Start-Sleep -Seconds 2
                Add-NTFSAccess -Path &quot;\\$NewServer\Users\$name&quot; -Account &quot;$Domain\$name&quot; -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles
            }
        }
    }

    END {}
}]]></description>
			<content:encoded><![CDATA[<p>This is an enhanced script you can use with a TXT file. Just put the names line by line into the TXT file and run the script with your custom server names and domain name. Change the drive letter to one you like.</p>
<p>Import-Module ActiveDirectory<br />
Import-Module NTFSSecurity</p>
<p>Function Migrate-UsersToNewHomeFolder {<br />
    [CmdletBinding()]<br />
    param(<br />
        [string[]] $UserName,<br />
        [string]   $OldServer = &#8216;OldServerName&#8217;,<br />
        [string]   $NewServer = &#8216;NewServerName&#8217;,<br />
        [string]   $Domain    = &#8216;domain.com&#8217;,<br />
        [string]   $UserListFile<br />
    )</p>
<p>    BEGIN {<br />
        Import-Module ActiveDirectory<br />
        Import-Module NTFSSecurity<br />
    }</p>
<p>    PROCESS {<br />
        if ($UserListFile -eq $null) {<br />
            Write-Error &#8220;Please provide a User file.&#8221;<br />
            return<br />
        }</p>
<p>        $UserList = Get-Content $UserListFile</p>
<p>        foreach ($name in $UserList) {<br />
            if ([bool](Get-ADUser -Filter {samaccountname -eq $name} )) {<br />
                Get-ADUser $name | Set-ADUser -HomeDrive H: -HomeDirectory &#8220;\\$NewServer\Users\$name&#8221;<br />
                robocopy &#8220;\\$OldServer\Users\$name&#8221; &#8220;\\$NewServer\Users\$name&#8221; /mir /copy:datou /r:1 /w:10<br />
                Start-Sleep -Seconds 2<br />
                Set-NTFSOwner -Path &#8220;\\$NewServer\Users\$name&#8221; -Account Administrators<br />
                Start-Sleep -Seconds 2<br />
                Add-NTFSAccess -Path &#8220;\\$NewServer\Users\$name&#8221; -Account &#8220;$Domain\$name&#8221; -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles<br />
            }<br />
        }<br />
    }</p>
<p>    END {}<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dave		</title>
		<link>https://thesysadminchannel.com/migrate-users-home-folder-new-file-server-using-powershell/#comment-17157</link>

		<dc:creator><![CDATA[Dave]]></dc:creator>
		<pubDate>Thu, 24 Aug 2023 18:37:47 +0000</pubDate>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=739#comment-17157</guid>

					<description><![CDATA[What is required in the Username String. I have entered a name in [] but when i run the script nothing happens. I would like to use a csv file with the user names .

Also i have change the security options 

This is what i have
 
    [CmdletBinding()]
        param(
            [Parameter(
                Mandatory=$true,
                ValueFromPipeline=$true,
                ValueFromPipelineByPropertyName=$true,
                Position=0)]
            [string[]] $UserName = [username], ## Can we user a .csv file here ??
 
            [string]   $OldServer = &#039;oldserver&#039;,
            [string]   $NewServer = &#039;newserver&#039;,
            [string]   $Domain    = &#039;Domain&#039;
             
        )

   
      
 
    BEGIN {}
    
    PROCESS {
        foreach ($name in $UserName) {
            if ([bool](Get-ADUser -Filter {samaccountname -eq $name} )) {
                Get-ADUser $name &#124; Set-ADUser -HomeDrive F: -HomeDirectory &quot;\$NewServer\Home\$name&quot;
                robocopy &quot;\$OldServer\Home\$Name&quot; &quot;\$NewServer\Home\$Name&quot; /mir /copy:datou /r:1 /w:10
                sleep 2
                Get-Acl -Path &quot;\$OldServer\Home\$Name&quot;
                #Set-NTFSOwner -Path &quot;\$NewServer\Home\$Name&quot; -Account Administrators
                sleep 2
                Set-Acl -Path &quot;\$NewServer\Home\$Name&quot;
                #Add-NTFSAccess -Path &quot;\$NewServer\Home\$Name&quot; -Account &quot;$Domain$name&quot; -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles
 
            }
        }
    }
 
    END {}
 
}]]></description>
			<content:encoded><![CDATA[<p>What is required in the Username String. I have entered a name in [] but when i run the script nothing happens. I would like to use a csv file with the user names .</p>
<p>Also i have change the security options </p>
<p>This is what i have</p>
<p>    [CmdletBinding()]<br />
        param(<br />
            [Parameter(<br />
                Mandatory=$true,<br />
                ValueFromPipeline=$true,<br />
                ValueFromPipelineByPropertyName=$true,<br />
                Position=0)]<br />
            [string[]] $UserName = [username], ## Can we user a .csv file here ??</p>
<p>            [string]   $OldServer = &#8216;oldserver&#8217;,<br />
            [string]   $NewServer = &#8216;newserver&#8217;,<br />
            [string]   $Domain    = &#8216;Domain&#8217;</p>
<p>        )</p>
<p>    BEGIN {}</p>
<p>    PROCESS {<br />
        foreach ($name in $UserName) {<br />
            if ([bool](Get-ADUser -Filter {samaccountname -eq $name} )) {<br />
                Get-ADUser $name | Set-ADUser -HomeDrive F: -HomeDirectory &#8220;\$NewServer\Home\$name&#8221;<br />
                robocopy &#8220;\$OldServer\Home\$Name&#8221; &#8220;\$NewServer\Home\$Name&#8221; /mir /copy:datou /r:1 /w:10<br />
                sleep 2<br />
                Get-Acl -Path &#8220;\$OldServer\Home\$Name&#8221;<br />
                #Set-NTFSOwner -Path &#8220;\$NewServer\Home\$Name&#8221; -Account Administrators<br />
                sleep 2<br />
                Set-Acl -Path &#8220;\$NewServer\Home\$Name&#8221;<br />
                #Add-NTFSAccess -Path &#8220;\$NewServer\Home\$Name&#8221; -Account &#8220;$Domain$name&#8221; -AccessRights FullControl -AccessType Allow -AppliesTo ThisFolderSubfoldersAndFiles</p>
<p>            }<br />
        }<br />
    }</p>
<p>    END {}</p>
<p>}</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
