Hello Ryan,
Yes, the script is ready. Here it is:
$homeDirectoryPath = "%homeDirectory%" # TODO: modify me
$destinationPath = "\\server\share\%username%" # TODO: modify me
# Script block
$scriptBlockToExecute = @"
& {
Copy-Item -Recurse -Path '$homeDirectoryPath' -Destination '$destinationPath' -Force
Remove-Item -Recurse '$homeDirectoryPath' -Force
}
"@
# Start Windows PowerShell as a separate process and run the script block in that process
$arguments = @("-noninteractive", "-noprofile", "-executionpolicy bypass", "-Command $scriptBlockToExecute")
$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)
In the script:
- $homeDirectoryPath: specifies a template for the user's home folder path. It is set to the %homeDirectory% value reference that will be replaced with the user's home folder path stored in the Home Directory property.
- $destinationPath: specifies a template for the path to the folder where the user's home folder will be moved.
Modify the script to your requirements.
To use the script in your Custom Command for deprovisioning:
- Launch Adaxes Administration Console.
- Locate and select the Custom Command that you use for deprovisioning.
- In the Result Pane (located to the right), double-click the built-in action that moves home directories of users.
- Select the Run a program or PowerShell script action and paste the above script in the Script field.
- Enter a short description for the script and click OK.
- Save the Custom Command.