If you want use the Script #2, make sure the the remote registry service is running on the computer. Also, my assumption is t if HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon/DefaultDomainName is not present, this computer is part of a WORKGROUP.