PowerShell: Vladimir Kolesnik, arvestus

From ICO wiki
Revision as of 09:51, 24 May 2011 by Vkolesni (talk | contribs) (Created page with '<source lang=powershell > function Set-IPAddress { param( [string]$networkinterface = "Local Area Connection", [string]$ip = $(read-host "Sisesta ip adresssi (naiteks 10.215…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
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