Script repository

Move large home folders

Updated on: Jan 18, 2026, Views: 3586

Folders and profiles

The built-in Move the home directory action can fail on large directories if the operation takes more than 10 minutes to complete. In such cases, the The pipeline has been stopped error will occur. The script works around this issue by creating a separate process to move a home folder.

Parameters

  • $sourcePath - the initial home directory path.
  • $destinationPath - the destination path where a home directory will be moved.
# Declare script to move home folders.
$scriptBlockToExecute = {
    $sourcePath = '%homeDirectory%' # TODO: modify me
    $destinationPath = '\\server\share\%username%' # TODO: modify me
    try
    {
        Copy-Item -Recurse -Path "$sourcePath" -Destination "$destinationPath" -Force -ErrorAction Stop
    }
    catch
    {
        return # Exit script
    }
    Remove-Item -Recurse "$sourcePath" -Force
}

# Start Windows PowerShell as a separate process to run the script
$arguments = @("-noninteractive", "-noprofile", "-executionpolicy bypass", "-Command " + $scriptBlockToExecute.ToString())
$powershellPath = "$env:windir\syswow64\windowspowershell\v1.0\powershell.exe"
$starProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$starProcessInfo.FileName = $powershellPath
$starProcessInfo.Arguments = $arguments
$starProcessInfo.WindowStyle = "Hidden"
$starProcessInfo.CreateNoWindow = $True
$process = [System.Diagnostics.Process]::Start($starProcessInfo)

Comments 2

You must be signed in to comment.

  • Grant

    Grant

    Can this script be updated so that it will still output errors to the Adaxes log from the external Powershell process?

    • Support

      Support

      Hello Grant,

      Unfortunately, there is no such possibility.

Got questions?

Support Questions & Answers

We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.