@kratkale
Renaming and Joining the domain as local PC admin localy worked with
$currentName = $env:COMPUTERNAME
IPv4-Adresse ermitteln, bei der das 3. Oktett = 0 ist$ip = Get-NetIPAddress -AddressFamily IPv4 |
Where-Object {
$.IPAddress -notlike “127.*” -and
$.PrefixOrigin -ne “WellKnown” -and
($_.IPAddress.Split(‘.’)[2] -eq ‘0’)
} |
Select-Object -First 1 -ExpandProperty IPAddress
if (-not $ip) {
Write-Host “Keine gültige IPv4-Adresse mit drittem Oktett = 0 gefunden!” -ForegroundColor Red
exit
}
$lastOctet = $ip.Split(‘.’)[-1]
Dreistellig formatieren$number = “{0:D3}” -f [int]$lastOctet
Neuer Name$newName = “PC${number}CAD”
AnzeigeWrite-Host “Aktueller Name: $currentName”
Write-Host “Gefundene IP: $ip”
Write-Host “Neuer Name: $newName”
Write-Host “”
$domain = “MM.HTLWIEN10.AT”
$username = “MM.HTLWIEN10.AT\adminfog”
$password = “xxxxxxxxxxxxxxxxxxxxx” | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Add-Computer -DomainName $domain -Credential $credential -Restart
so there seems to be no problem with the domain …