Extracting the last octet from local machines ip and applying to computer name
what trying on startup have script run (this new server only) looks @ ip assigned system (192.168.0.44) .. take last octet (44) , add newserver newserver44
$octet =
add-computer -domainname $domain -newname "newserverxx" -credential $credential -force -restart
i have tried . splt .. can not work
thanks
$ip = (get-wmiobject win32_networkadapterconfiguration -filter 'ipenabled=true').ipaddress[0] $lastoctet = $ip.split('.')[-1] $newservervar = "newserver$lastoctet" $newservervar
Windows Server > Windows PowerShell
Comments
Post a Comment