I'm trying to run the following PowerShell script to create a local user. This works in Windows Server 2008 R2 but I'm getting the error below on Windows Server 2012 RC. Any ideas on how to make this work in Windows Server 2012 RC?
$ComputerName = 'localhost'
$computer = [ADSI]"WinNT://$ComputerName"
$user = $computer.Create("User","Test")
$User.UserFlags = $User.UserFlags -bor 0x10000 #ADS_UF_DONT_EXPIRE_PASSWD flag is 0x10000
Thanks to someone on the Technet forum, the answer is to not use localhost for the computername. Here is the updated code.
$ComputerName = $env:ComputerName $computer = [ADSI]"WinNT://$ComputerName"
Hope it helps others.