Wednesday, June 20, 2018
Change IP from Windows command line using netsh.
Use the following command to change the ip of a network interface in Windows.
netsh interface ipv4 set address name="Ethernet0" static <new ip address> <subnet mask> <gateway>
Saturday, June 9, 2018
Change IP address using Powershell.
- Get-NetIPAddress
- get the InterfaceIndex number for the nic you want to change the IP address on.
- Remove-NetIPAddress -InterfaceIndex X
- New-NetIPAddress -InterfaceIndex X -IPAddress x.x.x.x -PrefixLength 23 -DefaultGateway x.x.x.x
- Set-DnsClientServerAddress -InterfaceIndex X -ServerAddresses x.x.x.x, x.x.x.x
Thursday, June 7, 2018
Get regkey value on a batch of computers remotely.
Here's a Powershell script I created to get value in the registry on a batch of computers remotely. Very handy if you have many computers to check. Will output 'Offline' if the computer is turned off.
$strMachineName = Get-Content computer_name.txt
foreach ($line in $strMachineName)
{
try{
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $line)
$regkey = $reg.OpenSubkey("<registry path>")
$serialkey = $regkey.GetValue("LicenseInformation")
if ($serialkey -eq ""){
write-host $line
}
}
catch{
write-host $line ----- "Offline"
}
}
Subscribe to:
Posts (Atom)