PowerShell: Vladimir Kolesnik, arvestus: Difference between revisions
From ICO wiki
Jump to navigationJump to search
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…' |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<source lang=powershell > | <source lang=powershell > | ||
#*********************************************************** | |||
# | |||
# 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 { | function Set-IPAddress { | ||
param( [string]$networkinterface = "Local Area Connection", | param( [string]$networkinterface = "Local Area Connection", |
Latest revision as of 09:54, 24 May 2011
#***********************************************************
#
# 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