You can generate a random name using the Get-Random cmdlet.
# Set allowed ASCII character codes to Uppercase letters (65..90),
$charcodes = 65..90
# Convert allowed character codes to characters
$allowedChars = $charcodes | ForEach-Object { [char][byte]$_ }
$LengthOfName = 10
# Generate computer name
$pw = ($allowedChars | Get-Random -Count $LengthOfName) -join ""
You can change a computer name with the cmdlet Rename-Computer. And to set it to run once, the easiest way would be to add an entry to the registry key
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
that will invoke PowerShell with your script.