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

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2