VMware Cloud Community
dwchan
Enthusiast
Enthusiast

Invoke-VMScript -Failed to authenticate with Win2016 server

I provisioned a simple Windows 2016 VM with autouattend.xml.   I logon and rename the computer name to "Win2016" (so it is not random).  and was able to kickoff an invoke-vmscript command.  However, as most VM is built with a random server name, is there a way to code my $DCLocalUser where the computer name is more less a wild card? versus right now is it "Win2016\Administrator"

$strVMName = "Win2016"
$DCLocalUser = "$strVMName\Administrator"
$DCLocalPWord = ConvertTo-SecureString -String 'Password' -AsPlainText -Force
$DCLocalCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $DCLocalUser, $DCLocalPWord

$ConfigureOSOT = 'Write-Verbose -Message "Configuring OSOT" -Verbose;
$OSOT = "VMwareOSOptimizationTool.exe";
$OSOTConfig = "VMwareOSOptimizationTool.exe.config";
$OSOTtemplate = "Windows10.xml";
D:\CustomFolder\VMware_OSOT\VMwareOSOptimizationTool.exe -o -t "VMware Templates\Windows 10 and Server 2016 or later" -r C:\Temp\'
Invoke-VMScript -ScriptText $ConfigureOSOT -VM $strVMName -GuestCredential $DCLocalCredential

0 Kudos
2 Replies
LucD
Leadership
Leadership

Not really, that would be a rather important security breach.

But why do you let it get a random name?
With unattended, you can specify a name in the ComputerName field in the XML.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
dwchan
Enthusiast
Enthusiast

Good point about injecting a name into unattend.xml during the build.   I will go down that path.  Thank you

0 Kudos