Manually remove Direct Access from a client

If the client is unable to do a DNS lookup, remove the following in the registry to disable/remove Direct Access DNS config.

$reg = 'HKLM:\SOFTWARE\Policies\Microsoft\`
Windows NT\DNSClient\DnsPolicyConfig'

Get-ChildItem -Path $reg | 
ForEach {Remove-Item $_.pspath}

Restart-Service DNSCache -force

Powershell: Rename remote computer with WMI

To rename a computer when Rename-Computer is not available (pre Powershell 4.0)

Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename(“NEWNAME”,”PASSWORD”,”USERNAME”)}

 

You can also mask the password

$credential = Get-Credential
Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename(“NEWNAME”,$credential.GetNetworkCredential().Password,$credential.Username)}