LucD I probably did not say specifically.
Network adapter 1 - this is the interface name when running the ipconfig command.
The script uses an alias, i.e. interface name in Control Panel > Network and Internet > Network Connections.
I use the alias for setting the network settings
IP address:
$ScriptText = 'New-NetIPAddress -InterfaceAlias "Ethernet0" -AddressFamily Ipv4 -IPAddress 10.10.10.210 -PrefixLength 24 -DefaultGateway 10.10.10.1'
DNS:
$ScriptText = 'Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 10.10.10.20'
Script for IP address, DNS, verification of the installed configuration:
$ScriptText = 'New-NetIPAddress -InterfaceAlias "Ethernet0" -AddressFamily Ipv4 -IPAddress 10.10.10.210 -PrefixLength 24 -DefaultGateway 10.10.10.1 | Out-Null;Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 10.10.10.20 | Out-Null;Start-Sleep -Seconds 5;Get-NetIPConfiguration -InterfaceAlias "Ethernet0"'
It is run by the cmdlet
Invoke-VMScript -ScriptText $ScriptText -VM TestVM -GuestCredential $GuestCredential
About the preliminary input of credentials for logging into the OS, I already wrote above ($GuestCredential = Get-Credentia