-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpc_Ports.ps1
34 lines (27 loc) · 1.68 KB
/
rpc_Ports.ps1
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
#Sets RPC port range
$port_range = '5000-5300'
$ports_available = 'Y'
$use_ports = 'Y'
if (Test-Path HKLM:\SOFTWARE\Microsoft\Rpc\Internet){
if (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Rpc\Internet -Name Ports -ErrorAction SilentlyContinue){
Set-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name Ports -Value $port_range -Type MultiString > $null
}
else {New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name Ports -Value $port_range -Type MultiString > $null
}
if (Get-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name PortsInternetAvailable -ErrorAction SilentlyContinue){
Set-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name PortsInternetAvailable -Value $ports_available -Type String > $null
}
else {New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name PortsInternetAvailable -Value 'Y' -Type String > $null
}
if (Get-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name UseInternetPorts -ErrorAction SilentlyContinue){
Set-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name UseInternetPorts -Value $use_ports -Type String > $null
}
else {New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name UseInternetPorts -Value 'Y' -Type String > $null
}
}
else { New-Item -Path HKLM:\Software\Microsoft\Rpc -Name Internet
New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name Ports -Value $port_range -Type MultiString > $null
New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name PortsInternetAvailable -Value 'Y' -Type String > $null
New-ItemProperty HKLM:\Software\Microsoft\Rpc\Internet -Name UseInternetPorts -Value 'Y' -Type String > $null
break
}