update
This commit is contained in:
22
Kemp/KEMP.ps1
Normal file
22
Kemp/KEMP.ps1
Normal file
@ -0,0 +1,22 @@
|
||||
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential bal -Verbose
|
||||
|
||||
# Set variables
|
||||
$ContentMatchingRuleName = "$CRPCEN_Authentic"
|
||||
$ContentMatchingRulePattern = "/^\/$CRPCEN-Authentic.*/"
|
||||
$VirtualServiceName = "10.80.20.2"
|
||||
$VirtualServicePort = 443
|
||||
$RealServerName = "xx-P-IIS-011.xx.net"
|
||||
$RealServerPort = 80
|
||||
$CheckUrl = "xx.xx.com"
|
||||
|
||||
# Create Content Rule
|
||||
New-AdcContentRule -RuleName $ContentMatchingRuleName -Header Host -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase true
|
||||
|
||||
# Create Sub Virtual Service
|
||||
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckHost $RealServerName -CheckPort $RealServerPort -CheckType http -CheckUrl $CheckUrl -CheckUse1_1 1 -Nickname $CheckUrl -VSType http -Weight 1000
|
||||
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckHost $RealServerName -CheckPort $RealServerPort -CheckType http -CheckUrl $CheckUrl -CheckUse1_1 1 -Nickname $CheckUrl -VSType http -Weight 900
|
||||
|
||||
# Add Real Server to Sub Virtual Service (disabled)
|
||||
New-AdcRealServer -RealServer $RealServerName -RealServerPort $RealServerPort -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 1000
|
153
Kemp/KEMP2.ps1
Normal file
153
Kemp/KEMP2.ps1
Normal file
@ -0,0 +1,153 @@
|
||||
Function KempAuthenticDuo {
|
||||
|
||||
[CmdletBinding()]
|
||||
PARAM (
|
||||
[Parameter(Mandatory=$true)][String] $CRPCEN,
|
||||
[Parameter(Mandatory=$true)][String] $PortPROXY,
|
||||
[Parameter(Mandatory=$true)][String] $Principal,
|
||||
[Parameter(Mandatory=$true)][String] $Secondaire,
|
||||
[Parameter()][String] $Description = $null
|
||||
)
|
||||
|
||||
#Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||
|
||||
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||
|
||||
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||
|
||||
#Variable
|
||||
$ContentMatchingRuleName = $CRPCEN+"_ui_Authentic"
|
||||
$ContentMatchingRulePattern = "/^\/$CRPCEN-ui-Authentic./"
|
||||
$VirtualServiceName = "10.80.20.2"
|
||||
$VirtualServicePort = 443
|
||||
$CheckedPort = $Port
|
||||
$SubVSName = "$CRPCEN-ui-Authentic"
|
||||
$Url = "/$CRPCEN-ui-Authentic/kemp.jsp"
|
||||
$AllowedVirtualHosts = "www.cloud-fichorga.fr"
|
||||
$AllowedVirtualDirectories = "/$CRPCEN-ui-Authentic*"
|
||||
$SchedulingMethod = "fixed"
|
||||
#$HTTPHeaderModifications = ""
|
||||
|
||||
# Creation Rules & Checking > Content Rules
|
||||
New-AdcContentRule -RuleName $ContentMatchingRuleName -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase 1
|
||||
|
||||
# Create Sub Virtual Service
|
||||
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||
|
||||
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckPort $PortPROXY -CheckType http -CheckUrl $Url -CheckUse1_1 0 -Nickname $SubVSName -VSType http -Weight 1000 -ESPEnabled $True -AllowedHosts $AllowedVirtualHosts -AllowedDirectories $AllowedVirtualDirectories -Schedule $SchedulingMethod -CheckUseGet 1 -AddVia 2 -StandByAddr 10.101.20.21 -StandByPort 8015
|
||||
|
||||
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 800
|
||||
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 700
|
||||
|
||||
}
|
||||
|
||||
Function KempAuthenticQuatro {
|
||||
|
||||
[CmdletBinding()]
|
||||
PARAM (
|
||||
[Parameter(Mandatory=$true)][String] $CRPCEN,
|
||||
[Parameter(Mandatory=$true)][String] $PortPROXY1,
|
||||
[Parameter(Mandatory=$true)][String] $PortPROXY2,
|
||||
[Parameter(Mandatory=$true)][String] $Principal,
|
||||
[Parameter(Mandatory=$true)][String] $Secondaire,
|
||||
[Parameter()][String] $Description = $null
|
||||
)
|
||||
|
||||
#Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||
|
||||
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||
|
||||
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||
|
||||
#Variable
|
||||
$ContentMatchingRuleName = $CRPCEN+"_ui_Authentic"
|
||||
$ContentMatchingRulePattern = "/^\/$CRPCEN-ui-Authentic./"
|
||||
$VirtualServiceName = "10.80.20.2"
|
||||
$VirtualServicePort = 443
|
||||
$CheckedPort = $Port
|
||||
$SubVSName = "$CRPCEN-ui-Authentic"
|
||||
$Url = "/$CRPCEN-ui-Authentic/kemp.jsp"
|
||||
$AllowedVirtualHosts = "www.cloud-fichorga.fr"
|
||||
$AllowedVirtualDirectories = "/$CRPCEN-ui-Authentic*"
|
||||
$SchedulingMethod = "fixed"
|
||||
#$HTTPHeaderModifications = ""
|
||||
|
||||
# Creation Rules & Checking > Content Rules
|
||||
New-AdcContentRule -RuleName $ContentMatchingRuleName -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase 1
|
||||
|
||||
# Create Sub Virtual Service
|
||||
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||
|
||||
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckPort $PortPROXY1 -CheckType http -CheckUrl $Url -CheckUse1_1 0 -Nickname $SubVSName -VSType http -Weight 1000 -ESPEnabled $True -AllowedHosts $AllowedVirtualHosts -AllowedDirectories $AllowedVirtualDirectories -Schedule $SchedulingMethod -CheckUseGet 1 -AddVia 2 -StandByAddr 10.101.20.21 -StandByPort 8015
|
||||
|
||||
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY1 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 1000
|
||||
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY2 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 800
|
||||
|
||||
Start-Sleep -s 5
|
||||
|
||||
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY1 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 900
|
||||
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY2 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 700
|
||||
|
||||
}
|
||||
|
||||
Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||
|
||||
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||
|
||||
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||
|
||||
Foreach($Line in Get-Content C:\tmp\CRPCEN.txt) {
|
||||
|
||||
If ($Line -ne $null) {
|
||||
$Line | foreach { $Line = $_ -split ';'
|
||||
$CRPCEN = $Line[0]
|
||||
$Serveur1 = $Line[1]
|
||||
$PortServeur1 = $Line[2]
|
||||
$PoidServeur1 = $Line[3]
|
||||
$Serveur2 = $Line[4]
|
||||
$PortServeur2 = $Line[5]
|
||||
$PoidServeur2 = $Line[6]
|
||||
$Serveur3 = $Line[7]
|
||||
$PortServeur3 = $Line[8]
|
||||
$PoidServeur3 = $Line[9]
|
||||
$Serveur4 = $Line[10]
|
||||
$PortServeur4 = $Line[11]
|
||||
$PoidServeur4 = $Line[12]
|
||||
} }
|
||||
|
||||
write-host "$CRPCEN"
|
||||
|
||||
If ($Serveur3 -ne '') {
|
||||
write-host "ici" $Serveur3
|
||||
|
||||
If ( $PoidServeur1 -lt $PoidServeur2 ) {
|
||||
write-host $CRPCEN $PortServeur1 $PortServeur2 $Serveur3 $Serveur1
|
||||
KempAuthenticQuatro $CRPCEN $PortServeur1 $PortServeur2 $Serveur3 $Serveur1
|
||||
}
|
||||
Else {
|
||||
write-host $CRPCEN $PortServeur1 $PortServeur2 $Serveur1 $Serveur3
|
||||
KempAuthenticQuatro $CRPCEN $PortServeur1 $PortServeur2 $Serveur1 $Serveur3
|
||||
}
|
||||
|
||||
}
|
||||
Else {
|
||||
write-host "la" $Serveur3
|
||||
|
||||
If ( $PoidServeur1 -lt $PoidServeur2 ) {
|
||||
write-host $CRPCEN $PortServeur1 $Serveur2 $Serveur1
|
||||
KempAuthenticDuo $CRPCEN $PortServeur1 $Serveur2 $Serveur1
|
||||
}
|
||||
Else {
|
||||
write-host $CRPCEN $PortServeur1 $Serveur1 $Serveur2
|
||||
KempAuthenticDuo $CRPCEN $PortServeur1 $Serveur1 $Serveur2
|
||||
}
|
||||
}
|
||||
|
||||
Start-Sleep -s 10
|
||||
|
||||
}
|
91
Kemp/Modification-KEMP.ps1
Normal file
91
Kemp/Modification-KEMP.ps1
Normal file
@ -0,0 +1,91 @@
|
||||
Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||
|
||||
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||
|
||||
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||
|
||||
#Variable
|
||||
$VirtualServiceName = "10.80.20.2"
|
||||
$VirtualServicePort = 443
|
||||
|
||||
$Liste = Get-AdcVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||
|
||||
$VSIndex = $Liste.Data.VS.subVS.VSIndex
|
||||
|
||||
Foreach ($VSClient in $VSIndex) {
|
||||
$NASVS = Get-AdcSubVirtualService -SubVSIndex $VSClient
|
||||
|
||||
$Temp = $NASVS.DATA.VS.NickName
|
||||
$IndexKemp = $NASVS.DATA.VS.index
|
||||
|
||||
$Temp | Foreach { $Temp = $_ -split '-'
|
||||
$ValueCRPCEN = $Temp[0]
|
||||
$ValueApp = $Temp[1]
|
||||
}
|
||||
|
||||
#foreach ($Ligne Get-Content clients.csv) {
|
||||
Foreach($Ligne in [System.IO.File]::ReadLines("D:\Data\Administration\app-2.csv")) {
|
||||
$Ligne | Foreach { $Ligne = $_ -split ';'
|
||||
$KempCRPCEN = $Ligne[0]
|
||||
$KempApp = $Ligne[1]
|
||||
$KempPrincipal = $Ligne[2]
|
||||
$KempSecondaire = $Ligne[3]
|
||||
$KempPort = $Ligne[4]
|
||||
}
|
||||
|
||||
If($KempCRPCEN -eq $ValueCRPCEN) {
|
||||
|
||||
If($KempApp -eq $ValueApp) {
|
||||
|
||||
#write-host $KempCRPCEN"/"$KempApp"/"$KempPrincipal"/"$KempSecondaire"/"$KempPort"/"$NASVS.DATA.VS.index
|
||||
|
||||
If (Test-Connection $KempPrincipal -count 1 -Quiet) {
|
||||
$ipV4Principal = Test-Connection "$KempPrincipal" -count 1 | select Ipv4Address
|
||||
|
||||
If ($ipV4Principal -ne $null) {
|
||||
$ipV4Principal | foreach { $ipV4Principal = $_ -split '='
|
||||
$ipV4PrincipalCLOUD = $ipV4Principal[1]
|
||||
}
|
||||
|
||||
$ipV4PrincipalCLOUD = $ipV4PrincipalCLOUD -replace " ", ""
|
||||
$ipV4PrincipalCLOUD = $ipV4PrincipalCLOUD -replace "}", ""
|
||||
}
|
||||
Else {
|
||||
$ipV4Principal = "0.0.0.0"
|
||||
$ipV4PrincipalCLOUD = "0.0.0.0"
|
||||
}
|
||||
#write-host "$ipV4PrincipalCLOUD"
|
||||
}
|
||||
|
||||
If (Test-Connection $KempSecondaire -count 1 -Quiet) {
|
||||
$ipV4Secondaire = Test-Connection "$KempSecondaire" -count 1 | select Ipv4Address
|
||||
|
||||
If ($ipV4Secondaire -ne $null) {
|
||||
$ipV4Secondaire | foreach { $ipV4Secondaire = $_ -split '='
|
||||
$ipV4SecondaireCLOUD = $ipV4Secondaire[1]
|
||||
}
|
||||
|
||||
$ipV4SecondaireCLOUD = $ipV4SecondaireCLOUD -replace " ", ""
|
||||
$ipV4SecondaireCLOUD = $ipV4SecondaireCLOUD -replace "}", ""
|
||||
}
|
||||
Else {
|
||||
$ipV4Secondaire = "0.0.0.0"
|
||||
$ipV4SecondaireCLOUD = "0.0.0.0"
|
||||
}
|
||||
#write-host "$ipV4SecondaireCLOUD"
|
||||
}
|
||||
write-host $KempCRPCEN"-"$KempApp":"$ipV4PrincipalCLOUD"/"$ipV4SecondaireCLOUD"-"$KempPort"-"$IndexKemp
|
||||
New-AdcRealServer -RealServer $ipV4PrincipalCLOUD -RealServerPort $KempPort -Enable $true -Forward nat -VSIndex $IndexKemp -Weight 800
|
||||
New-AdcRealServer -RealServer $ipV4SecondaireCLOUD -RealServerPort $KempPort -Enable $true -Forward nat -VSIndex $IndexKemp -Weight 700
|
||||
Start-Sleep -s 5
|
||||
}
|
||||
Else {
|
||||
|
||||
}
|
||||
}
|
||||
Else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
0
Kemp/README.md
Normal file
0
Kemp/README.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,120 @@
|
||||
#
|
||||
# Module manifest for module 'Kemp.LoadBalancer.Powershell'
|
||||
#
|
||||
# Generated by: KEMP
|
||||
#
|
||||
# Generated on: Nov 30 2017
|
||||
#
|
||||
|
||||
@{
|
||||
|
||||
# Script module or binary module file associated with this manifest.
|
||||
RootModule = 'Kemp.LoadBalancer.Powershell.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '7.2.40.0'
|
||||
|
||||
# ID used to uniquely identify this module
|
||||
GUID = 'fb76aa2c-d5f7-11e7-b122-000af7388c80'
|
||||
|
||||
# Author of this module
|
||||
Author = 'Fabrizio Carpin'
|
||||
|
||||
# Company or vendor of this module
|
||||
CompanyName = 'KEMP Technologies'
|
||||
|
||||
# Copyright statement for this module
|
||||
Copyright = '(c) 2017. All rights reserved.'
|
||||
|
||||
# Description of the functionality provided by this module
|
||||
Description = 'KEMP Load Balancer Powershell Module'
|
||||
|
||||
# Minimum version of the Windows PowerShell engine required by this module
|
||||
PowerShellVersion = '2.0'
|
||||
|
||||
# Name of the Windows PowerShell host required by this module
|
||||
# PowerShellHostName = ''
|
||||
|
||||
# Minimum version of the Windows PowerShell host required by this module
|
||||
PowerShellHostVersion = '2.0'
|
||||
|
||||
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||
DotNetFrameworkVersion = '2.0'
|
||||
|
||||
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||
CLRVersion = '2.0.50727.0'
|
||||
|
||||
# Processor architecture (None, X86, Amd64) required by this module
|
||||
ProcessorArchitecture = 'None'
|
||||
|
||||
# Modules that must be imported into the global environment prior to importing this module
|
||||
# RequiredModules = @()
|
||||
|
||||
# Assemblies that must be loaded prior to importing this module
|
||||
RequiredAssemblies = @()
|
||||
|
||||
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
||||
ScriptsToProcess = @()
|
||||
|
||||
# Type files (.ps1xml) to be loaded when importing this module
|
||||
TypesToProcess = @()
|
||||
|
||||
# Format files (.ps1xml) to be loaded when importing this module
|
||||
FormatsToProcess = @()
|
||||
|
||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||
NestedModules = @()
|
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = '*'
|
||||
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
CmdletsToExport = '*'
|
||||
|
||||
# Variables to export from this module
|
||||
VariablesToExport = '*'
|
||||
|
||||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
|
||||
AliasesToExport = '*'
|
||||
|
||||
# DSC resources to export from this module
|
||||
# DscResourcesToExport = @()
|
||||
|
||||
# List of all modules packaged with this module
|
||||
ModuleList = @()
|
||||
|
||||
# List of all files packaged with this module
|
||||
FileList = @()
|
||||
|
||||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
||||
PrivateData = @{
|
||||
|
||||
PSData = @{
|
||||
|
||||
# Tags applied to this module. These help with module discovery in online galleries.
|
||||
# Tags = @()
|
||||
|
||||
# A URL to the license for this module.
|
||||
# LicenseUri = ''
|
||||
|
||||
# A URL to the main website for this project.
|
||||
# ProjectUri = ''
|
||||
|
||||
# A URL to an icon representing this module.
|
||||
# IconUri = ''
|
||||
|
||||
# ReleaseNotes of this module
|
||||
ReleaseNotes = 'BUILD: 1159'
|
||||
|
||||
} # End of PSData hashtable
|
||||
|
||||
} # End of PrivateData hashtable
|
||||
|
||||
# HelpInfo URI of this module
|
||||
# HelpInfoURI = ''
|
||||
|
||||
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
|
||||
# DefaultCommandPrefix = ''
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
7771
Kemp/modules/Kemp.LoadBalancer.Powershell/deprecated.psm1
Normal file
7771
Kemp/modules/Kemp.LoadBalancer.Powershell/deprecated.psm1
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user