Powershell 2.0でのネットワーク関連の操作方法
Powershellでネットワーク設定を行う
http://viewse.blogspot.jp/2011/11/powershell-win32networkadapterconfigura.html
Powershell 3.0(Windows Server 2012,Windows8)ではネットワーク操作用のコマンドレットが用意されていますが、Powershell 2.0ではWin32_NetworkAdapterConfigurationを使ってIP設定等を行うようです
Windows PowerShell Cmdlets for Networking
適用対象: Windows Server 2012
http://technet.microsoft.com/ja-jp/library/jj717268.aspx
ならばWindows 7にPowershel 3.0をインストールすればこのコマンドレットが使えるようになるのかな?
Installing Windows PowerShell
http://technet.microsoft.com/en-us/library/hh847837.aspx
1 2 3 4 5 6 7 8 9 10 |
PS C:\> Get-WmiObject Win32_NetworkAdapterConfiguration (snip) DHCPEnabled : False IPAddress : {192.168.1.10} DefaultIPGateway : {192.168.1.1} DNSDomain : ServiceName : e1cexpress Description : Intel(R) 82579V Gigabit Network Connection Index : 7 (snip) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
PS C:\> $net | ? {$_.DNSServerSearchOrder} DHCPEnabled : False IPAddress : {192.168.1.10} DefaultIPGateway : {192.168.1.1} DNSDomain : ServiceName : e1cexpress Description : Intel(R) 82579V Gigabit Network Connection Index : 7 PS C:\> $net | ? {$_.IPSubnet} DHCPEnabled : False IPAddress : {192.168.1.10} DefaultIPGateway : {192.168.1.1} DNSDomain : ServiceName : e1cexpress Description : Intel(R) 82579V Gigabit Network Connection Index : 7 |
う~~ん、いまいち使いこなせない
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
PS C:\> Get-WmiObject Win32_NetworkAdapterConfiguration | gm TypeName: System.Management.ManagementObject#root\cimv2\Win32_NetworkAdapterConfiguration Name MemberType Definition ---- ---------- ---------- DisableIPSec Method System.Management.ManagementBaseObject DisableIPSec() EnableDHCP Method System.Management.ManagementBaseObject EnableDHCP() EnableIPSec Method System.Management.ManagementBaseObject EnableIPSec(System.String[] IPSecPe... EnableStatic Method System.Management.ManagementBaseObject EnableStatic(System.String[] IPAddr... ReleaseDHCPLease Method System.Management.ManagementBaseObject ReleaseDHCPLease() RenewDHCPLease Method System.Management.ManagementBaseObject RenewDHCPLease() SetDNSDomain Method System.Management.ManagementBaseObject SetDNSDomain(System.String DNSDomain) SetDNSServerSearchOrder Method System.Management.ManagementBaseObject SetDNSServerSearchOrder(System.Stri... SetDynamicDNSRegistration Method System.Management.ManagementBaseObject SetDynamicDNSRegistration(System.Bo... SetGateways Method System.Management.ManagementBaseObject SetGateways(System.String[] Default... SetIPConnectionMetric Method System.Management.ManagementBaseObject SetIPConnectionMetric(System.UInt32... SetIPXFrameTypeNetworkPairs Method System.Management.ManagementBaseObject SetIPXFrameTypeNetworkPairs(System.... SetTcpipNetbios Method System.Management.ManagementBaseObject SetTcpipNetbios(System.UInt32 Tcpip... SetWINSServer Method System.Management.ManagementBaseObject SetWINSServer(System.String WINSPri... ArpAlwaysSourceRoute Property System.Boolean ArpAlwaysSourceRoute {get;set;} ArpUseEtherSNAP Property System.Boolean ArpUseEtherSNAP {get;set;} Caption Property System.String Caption {get;set;} DatabasePath Property System.String DatabasePath {get;set;} DeadGWDetectEnabled Property System.Boolean DeadGWDetectEnabled {get;set;} DefaultIPGateway Property System.String[] DefaultIPGateway {get;set;} DefaultTOS Property System.Byte DefaultTOS {get;set;} DefaultTTL Property System.Byte DefaultTTL {get;set;} Description Property System.String Description {get;set;} DHCPEnabled Property System.Boolean DHCPEnabled {get;set;} DHCPLeaseExpires Property System.String DHCPLeaseExpires {get;set;} DHCPLeaseObtained Property System.String DHCPLeaseObtained {get;set;} DHCPServer Property System.String DHCPServer {get;set;} DNSDomain Property System.String DNSDomain {get;set;} DNSDomainSuffixSearchOrder Property System.String[] DNSDomainSuffixSearchOrder {get;set;} DNSEnabledForWINSResolution Property System.Boolean DNSEnabledForWINSResolution {get;set;} DNSHostName Property System.String DNSHostName {get;set;} DNSServerSearchOrder Property System.String[] DNSServerSearchOrder {get;set;} DomainDNSRegistrationEnabled Property System.Boolean DomainDNSRegistrationEnabled {get;set;} ForwardBufferMemory Property System.UInt32 ForwardBufferMemory {get;set;} FullDNSRegistrationEnabled Property System.Boolean FullDNSRegistrationEnabled {get;set;} GatewayCostMetric Property System.UInt16[] GatewayCostMetric {get;set;} IGMPLevel Property System.Byte IGMPLevel {get;set;} Index Property System.UInt32 Index {get;set;} InterfaceIndex Property System.UInt32 InterfaceIndex {get;set;} IPAddress Property System.String[] IPAddress {get;set;} IPConnectionMetric Property System.UInt32 IPConnectionMetric {get;set;} IPEnabled Property System.Boolean IPEnabled {get;set;} IPFilterSecurityEnabled Property System.Boolean IPFilterSecurityEnabled {get;set;} IPPortSecurityEnabled Property System.Boolean IPPortSecurityEnabled {get;set;} IPSecPermitIPProtocols Property System.String[] IPSecPermitIPProtocols {get;set;} IPSecPermitTCPPorts Property System.String[] IPSecPermitTCPPorts {get;set;} IPSecPermitUDPPorts Property System.String[] IPSecPermitUDPPorts {get;set;} IPSubnet Property System.String[] IPSubnet {get;set;} IPUseZeroBroadcast Property System.Boolean IPUseZeroBroadcast {get;set;} IPXAddress Property System.String IPXAddress {get;set;} IPXEnabled Property System.Boolean IPXEnabled {get;set;} IPXFrameType Property System.UInt32[] IPXFrameType {get;set;} IPXMediaType Property System.UInt32 IPXMediaType {get;set;} IPXNetworkNumber Property System.String[] IPXNetworkNumber {get;set;} IPXVirtualNetNumber Property System.String IPXVirtualNetNumber {get;set;} KeepAliveInterval Property System.UInt32 KeepAliveInterval {get;set;} KeepAliveTime Property System.UInt32 KeepAliveTime {get;set;} MACAddress Property System.String MACAddress {get;set;} MTU Property System.UInt32 MTU {get;set;} NumForwardPackets Property System.UInt32 NumForwardPackets {get;set;} PMTUBHDetectEnabled Property System.Boolean PMTUBHDetectEnabled {get;set;} PMTUDiscoveryEnabled Property System.Boolean PMTUDiscoveryEnabled {get;set;} ServiceName Property System.String ServiceName {get;set;} SettingID Property System.String SettingID {get;set;} TcpipNetbiosOptions Property System.UInt32 TcpipNetbiosOptions {get;set;} TcpMaxConnectRetransmissions Property System.UInt32 TcpMaxConnectRetransmissions {get;set;} TcpMaxDataRetransmissions Property System.UInt32 TcpMaxDataRetransmissions {get;set;} TcpNumConnections Property System.UInt32 TcpNumConnections {get;set;} TcpUseRFC1122UrgentPointer Property System.Boolean TcpUseRFC1122UrgentPointer {get;set;} TcpWindowSize Property System.UInt16 TcpWindowSize {get;set;} WINSEnableLMHostsLookup Property System.Boolean WINSEnableLMHostsLookup {get;set;} WINSHostLookupFile Property System.String WINSHostLookupFile {get;set;} WINSPrimaryServer Property System.String WINSPrimaryServer {get;set;} WINSScopeID Property System.String WINSScopeID {get;set;} WINSSecondaryServer Property System.String WINSSecondaryServer {get;set;} __CLASS Property System.String __CLASS {get;set;} __DERIVATION Property System.String[] __DERIVATION {get;set;} __DYNASTY Property System.String __DYNASTY {get;set;} __GENUS Property System.Int32 __GENUS {get;set;} __NAMESPACE Property System.String __NAMESPACE {get;set;} __PATH Property System.String __PATH {get;set;} __PROPERTY_COUNT Property System.Int32 __PROPERTY_COUNT {get;set;} __RELPATH Property System.String __RELPATH {get;set;} __SERVER Property System.String __SERVER {get;set;} __SUPERCLASS Property System.String __SUPERCLASS {get;set;} DHCP PropertySet DHCP {Description, DHCPEnabled, DHCPLeaseExpires, DHCPLeaseObtained, DHCPS... DNS PropertySet DNS {Description, DNSDomain, DNSDomainSuffixSearchOrder, DNSEnabledForWINS... IP PropertySet IP {Description, Index, IPAddress, IPConnectionMetric, IPEnabled, IPFilter... PSStatus PropertySet PSStatus {DHCPLeaseExpires, Index, Description} WINS PropertySet WINS {Description, Index, WINSEnableLMHostsLookup, WINSHostLookupFile, WIN... ConvertFromDateTime ScriptMethod System.Object ConvertFromDateTime(); ConvertToDateTime ScriptMethod System.Object ConvertToDateTime(); |