Archiving home folders

The following code sample archives a user's home directory to a ZIP file.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$archivePath = "\\SERVER\share\JSmith.zip"
$compressionLevel = 1

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Archive the user's home folder
$user.ArchiveHomeDirectory($archivePath, $compressionLevel)

See also