PowerShell: Vladimir Kolesnik, arvestus
From ICO wiki
Jump to navigationJump to search
#***********************************************************
#
# Skripti nimi: changenetwork.ps1
# Autor: Vladimir Kolesnik
# Ryhm: A22
# Versioon: 1.0
# Kuupaev: 24 May, 2011
#
# Selgitus: antud skript voimaldab muuta igasuguseid vorguandmeid
# Naiteks: IP adress, default gateway ja subnet mask
#
#************************************************************
function Set-IPAddress {
param( [string]$networkinterface = "Local Area Connection",
[string]$ip = $(read-host "Sisesta ip adresssi (naiteks 10.215.1.10)"),
[string]$mask = $(read-host "Sisesta vorgumaski (naiteks 255.255.0.0)"),
[string]$gateway = $(read-host "Sisesta vaikelyys (naiteks 10.215.1.250"),
[string]$dns1 = "10.210.1.101",
[string]$dns2 = "10.210.1.130",
[string]$registerDns = "TRUE"
)
#Hakkame kirjutama sisestatud andmeid
$dns = $dns1
if($dns2){$dns ="$dns1,$dns2"}
$index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq $networkinterface}).InterfaceIndex
$NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index}
$NetInterface.EnableStatic($ip, $mask)
$NetInterface.SetGateways($gateway)
$NetInterface.SetDNSServerSearchOrder($dns)
$NetInterface.SetDynamicDNSRegistration($registerDns)
}
Set-IPAddress