Page 1 of 1

Transwiz profile backup package

Published: August 13, 2024 - 12:18
by gch14800
Good morning,

I am preparing a package to allow the migration of Windows user profiles by creating a "backup" package and a "restore" package.

However, I have a small doubt, I made a .ps1 script in my WAPT package, however, to define my "Username" variable I don't really know how to do it.

The package runs a PowerShell script that contains this
$backupDir = "\\xxxxx\users"
$transwizPath = ".\Transwiz.exe"

Start-Process -FilePath $transwizPath -ArgumentList "/la", "/p:$backupDir", "/n:$Username" -Wait
:

I don't know how to make the $username variable the last logged-in WAPT user, any ideas?

Re: Transwiz profile backup package

Published: August 14, 2024 - 12:58
by sfonteneau
Hmm, it's a bit complicated to determine...

We can retrieve the logged-in users... but that's not what we want.

We can retrieve HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser

, but that's not ideal either.

We can sort the ntuser.dat files and check for the most recent one, but that's not ideal either.

Furthermore, using a "username" isn't ideal in cases where Active Directory isn't available; the SID to username resolution will fail.