PowerShell Switch: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) K |
||
Zeile 23: | Zeile 23: | ||
*Mellanox Network-Card in a Node with 14 physical Cores per CPU | *Mellanox Network-Card in a Node with 14 physical Cores per CPU | ||
*Mellanox Network-Card in a Node with 8 physical Cores per CPU | *Mellanox Network-Card in a Node with 8 physical Cores per CPU | ||
+ | |||
<source lang="powershell"> | <source lang="powershell"> |
Version vom 4. Juni 2018, 14:28 Uhr
Example of a basic PowerShell Switch
$SwitchName = <Get-...> #Get-Command or something similar Switch ($SwitchName) { "Name 1" {$SwitchNumber = 1; break} #Answer to the Get-Command = "Name 1" "Name 2" {$SwitchNumber = 2; break} #Answer to the Get-Command = "Name 2" } Switch ($SwitchNumber) { 1 {Write-Host "Name 1 is selected, do someting"} 2 {Write-Host "Name 2 is selected, do someting"} }
Example of a PowerShell Switch to configure RSS-Settings
This example is for 4 variant of RSS-Settings
- Chelsio Network-Card in a Node with 14 physical Cores per CPU
- Chelsio Network-Card in a Node with 8 physical Cores per CPU
- Mellanox Network-Card in a Node with 14 physical Cores per CPU
- Mellanox Network-Card in a Node with 8 physical Cores per CPU
#Configure Core Mapping $CPUProperty = "NumberOfCores","NumberOfLogicalProcessors" $StandardNumberOfCores = 14 $HighClockNumberOfCores = 8 $NumberOfCores = (Get-WmiObject -class win32_processor -Property $CPUProperty).NumberOfCores[0] #Find Network Hardwarde Vendor $NetworkVendorName = (Get-WmiObject -class win32_networkAdapter -Property "Name").name # Set Vendor Number # 1 = Chelsio # 2 = Mellanox HP 546FLR switch ($NetworkVendorName) { "Chelsio Network Adapter" {$NetworkVendorNumber = 1 ; break} "HP Ethernet 10G 2-port 546FLR-SFP+ Adapter"{$NetworkVendorNumber = 2 ; break} } #------------------------------------------------------------------------------------------------ switch ($NetworkVendorNumber) { 1 { #RSS-Settings für Chelsio / Stand 07.05.2018 Enable-NetAdapterRSS -Name NIC01 Enable-NetAdapterRSS -Name NIC02 #Standard Hyper-V Nodes für Chelsio If ($NumberOfCores -eq $StandardNumberOfCores) { Write-Verbose "Setze RSS für Standard Hyper-V Nodes für Chelsio" Set-NetAdapterRss -Name NIC01 -BaseProcessorGroup 0 -BaseProcessorNumber 2 -MaxProcessors 8 -MaxProcessorNumber 26 -Profile Closest -NumaNode 0 Set-NetAdapterRss -Name NIC02 -BaseProcessorGroup 0 -BaseProcessorNumber 30 -MaxProcessors 8 -MaxProcessorNumber 54 -Profile Closest -NumaNode 1 } #High-clock Hyper-V Nodes für Chelsio ElseIf ($NumberOfCores -eq $HighClockNumberOfCores) { Write-Verbose "Setze RSS für High-clock Hyper-V Nodes für Chelsio" Set-NetAdapterRss -Name NIC01 -BaseProcessorGroup 0 -BaseProcessorNumber 2 -MaxProcessors 7 -MaxProcessorNumber 14 -Profile Closest -NumaNode 0 Set-NetAdapterRss -Name NIC02 -BaseProcessorGroup 0 -BaseProcessorNumber 18 -MaxProcessors 7 -MaxProcessorNumber 30 -Profile Closest -NumaNode 1 } break } 2 { #RSS-Settings für Mellanox HP / Stand 07.05.2018 Enable-NetAdapterVmq -Name NIC01 Enable-NetAdapterVmq -Name NIC02 #Standard Hyper-V Nodes für HP Mellanox If ($NumberOfCores -eq $StandardNumberOfCores) { Write-Verbose "Setze RSS für Standard Hyper-V Nodes für HP Mellanox" Set-NetAdapterRss -Name NIC01 -BaseProcessorGroup 0 -BaseProcessorNumber 2 -MaxProcessors 6 -MaxProcessorNumber 12 -Profile Closest -NumaNode 0 Set-NetAdapterRss -Name NIC02 -BaseProcessorGroup 0 -BaseProcessorNumber 14 -MaxProcessors 6 -MaxProcessorNumber 24 -Profile Closest -NumaNode 0 } #High-clock Hyper-V Nodes für Mellanox HP / Stand 07.05.2018 ElseIf ($NumberOfCores -eq $HighClockNumberOfCores) { Write-Verbose "Setze RSS für High-clock Hyper-V Nodes für Mellanox HP" Set-NetAdapterRss -Name NIC01 -BaseProcessorGroup 0 -BaseProcessorNumber 2 -MaxProcessors 3 -MaxProcessorNumber 6 -Profile Closest -NumaNode 0 Set-NetAdapterRss -Name NIC02 -BaseProcessorGroup 0 -BaseProcessorNumber 8 -MaxProcessors 3 -MaxProcessorNumber 12 -Profile Closest -NumaNode 0 } break } }