소스 검색

Update 'Change IPaddress.ps1'

Commented out unneeded ipconfigs
delta 2 년 전
부모
커밋
6cb0ab29ec
1개의 변경된 파일38개의 추가작업 그리고 38개의 파일을 삭제
  1. 38
    38
      Change IPaddress.ps1

+ 38
- 38
Change IPaddress.ps1 파일 보기

@@ -1,38 +1,38 @@
1
-if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
2
-    Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
3
-    exit;
4
-}
5
-Get-NetAdapter
6
-
7
-$ifIndex = read-host "Interface Index:"
8
-$NetworkInput = read-host "Network (First 3 Octets):"
9
-$HostInput = Read-Host "Host address (Last Octet):"
10
-$IPAddress = $NetworkInput +"."+$HostInput
11
-$SubnetmaskInput = read-host "Subnet Mask Or Last Octet(/24):"
12
-if($SubnetmaskInput -eq '') {$SubnetmaskInput= "24"}
13
-$DefaultGatewayInput = read-host "Default Gateway (Last Octet):"
14
-$DefaultGateway = $NetworkInput +"."+$DefaultGatewayInput
15
-
16
-Switch ($SubnetmaskInput)
17
-{
18
-24 {$Mask = $SubnetmaskInput}
19
-32 {$Mask = $SubnetmaskInput}
20
-30 {$Mask = $SubnetmaskInput}
21
-29 {$Mask = $SubnetmaskInput}
22
-0 {$Mask = 24}
23
-255 {$Mask = 32}
24
-252 {$Mask = 30}
25
-248 {$Mask = 29}
26
-
27
-Default {'Invalid Subnet Mask'}
28
-}
29
-
30
-ipconfig /all
31
-New-NetIPAddress -InterfaceIndex $ifIndex -IPAddress $IPAddress -PrefixLength $Mask -DefaultGateway $DefaultGateway
32
-ipconfig /all
33
-pause
34
-Remove-NetIPAddress -IPAddress $IPAddress -DefaultGateway $DefaultGateway
35
-Set-NetIPInterface -InterfaceIndex $ifIndex -Dhcp Enabled
36
-ipconfig /all
37
-ipconfig /renew
38
-pause
1
+if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
2
+    Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
3
+    exit;
4
+}
5
+Get-NetAdapter
6
+
7
+$ifIndex = read-host "Interface Index:"
8
+$NetworkInput = read-host "Network (First 3 Octets):"
9
+$HostInput = Read-Host "Host address (Last Octet):"
10
+$IPAddress = $NetworkInput +"."+$HostInput
11
+$SubnetmaskInput = read-host "Subnet Mask Or Last Octet(/24):"
12
+if($SubnetmaskInput -eq '') {$SubnetmaskInput= "24"}
13
+$DefaultGatewayInput = read-host "Default Gateway (Last Octet):"
14
+$DefaultGateway = $NetworkInput +"."+$DefaultGatewayInput
15
+
16
+Switch ($SubnetmaskInput)
17
+{
18
+24 {$Mask = $SubnetmaskInput}
19
+32 {$Mask = $SubnetmaskInput}
20
+30 {$Mask = $SubnetmaskInput}
21
+29 {$Mask = $SubnetmaskInput}
22
+0 {$Mask = 24}
23
+255 {$Mask = 32}
24
+252 {$Mask = 30}
25
+248 {$Mask = 29}
26
+
27
+Default {'Invalid Subnet Mask'}
28
+}
29
+
30
+#ipconfig /all
31
+New-NetIPAddress -InterfaceIndex $ifIndex -IPAddress $IPAddress -PrefixLength $Mask -DefaultGateway $DefaultGateway
32
+#ipconfig /all
33
+pause
34
+Remove-NetIPAddress -IPAddress $IPAddress -DefaultGateway $DefaultGateway
35
+Set-NetIPInterface -InterfaceIndex $ifIndex -Dhcp Enabled
36
+#ipconfig /all
37
+ipconfig /renew
38
+pause

Powered by TurnKey Linux.