Yes, that’s a good alternative, especially if system folders have been moved. You can also extend this method to the other queries in the script, like this:
$HOSTNAME = [Environment]::MachineName # Computer name
$USERROOT = [Environment]::GetFolderPath(“UserProfile”) # Current user’s root path
$ADAT = [Environment]::GetFolderPath(“ApplicationData”) # Path to user-specific application data - Roaming
$ADATLOC = [Environment]::GetFolderPath(“LocalApplicationData”) # Path to user-specific application data - Local
$DOCS = [Environment]::GetFolderPath(“MyDocuments”) # Path to user documents