MarvellFastlinqCmdlets.psm1
<#
WINDOWS EIT POWERSHELL PROFILE is a script which contains functions to ease manual efforts in day to day testing. It has functions/commands which can be used right from configuring a freshly installed OS to complex test configurations and verifications. #> <# Some of the functions depends on hardcoded variables and scripts. 1. Corporate IP starts with "10.30*". This is used to create Management vswitch and Turning on Debugger. 2. Drivers for installations are being taken from a local repository 3. Software are getting copied/installed from QIDL local repository] #> #Get-Device # [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property Status -ne "Disabled" | Where-Object -Property Status -ne "Disconnected" | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name #Global variable $username = 'Administrator' $usernameWineit = 'wineit\Administrator' $usernameWindowseit = 'windows\Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $credWineit = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $usernameWineit, $pass $credWindowseit = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $usernameWindowseit, $pass $corpAddress="10.*" $driverLocation="" $softwareShareLocation="" #firing command on remote machine $RunOnPeerAsWell; #initial_config on a fresh installed OS including software installations, seeting dump mode to kernal and more. function initial-config { param( $VBDVersion, $NDISVersion, [ValidateSet("retail", "checked")]$DriverType, $Hostname, $Install_Hyper_v=1 ) #Hostname if ($Hostname) {Write-Host Changing hostname to $Hostname; Rename-Computer -NewName $hostname } #Enable Remote desktop Write-host Enable Remote desktop cscript C:\Windows\System32\SCregEdit.wsf /ar 0 #Auto logon Write-Host Enabling Autologon Autologon #Disable Network Level Authentication Write-host "Disable Network Level Authentication for RDP" $ComputerName = hostname (Get-WmiObject -class Win32_TSGeneralSetting -Namespace root\cimv2\terminalservices -ComputerName $ComputerName -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0) #disabling Server Manager on Startup Write-host Disabling Server Manager on Startup Dis-SeverManagerOnStartup #WinRm client Write-host Setting trusted host settings winrm.cmd quickconfig set-item wsman:\localhost\Client\TrustedHosts -value * -Force -Verbose #set time zone to IST Write-Host Set time zone to IST settime #turn off display never (Useful in case of VMs and Raritan/Console) Write-Host Never turn off display powercfg -change -monitor-timeout-ac 0 powercfg -change -monitor-timeout-dc 0 powercfg -change -standby-timeout-ac 0 powercfg -change -standby-timeout-dc 0 #disable IEEnhanced Security Configuration Write-Host disable IEEnhanced Security Configuration Dis-InternetExplorerESC -Verbose #Disable UserAccessControl Write-Host Disable UserAccessControl Dis-UserAccessControl -Verbose #Set Memory Dump mode Write-Host Set OS dump mode to kernal dump #Set OS dump mode # 0 = None # 1 = Complete memory dump # 2 = Kernel memory dump # 3 = Small memory dump Get-WmiObject -Class Win32_OSRecoveryConfiguration -EnableAllPrivileges | Set-WmiInstance -Arguments @{ DebugInfoType = 2 } #Check if its set (Get-WmiObject -Class Win32_OSRecoveryConfiguration).DebugInfoType <# #Disable Overwriting existing dump files #More information on https://docs.microsoft.com/en-us/windows/client-management/system-failure-recovery-options Write-Host Disabling Overwriting existing dump files wmic recoveros set OverwriteExistingDebugFile = 0 #> #Hyper-V #Check Hyper-V state if($Install_Hyper_v) { if ((Get-WindowsFeature hyper-v).installstate -ne 'installed' -and (Get-WmiObject -Class Win32_computersystem).model -ne "Virtual Machine") { Get-WindowsFeature *hyper* | Install-WindowsFeature -Verbose } else { Write-Host "`nHyper-V is already installed..." } } #Rename partition and boot entry OsOnPartitions #Install drivers if ($VBDVersion) { Install-VBD $VBDVersion $DriverType } if ($NDISVersion) { Install-NDIS $NDISVersion $DriverType } #Installing tools #Installing Medusa $instChk = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Medusa" if ($instChk -ne $null) { Write-Host " Medusa is already installed on System" -ForegroundColor Green } else { Write-Host " Installing Medusa on System" -ForegroundColor Yellow #Start-Process -Wait -FilePath "\\10.30.35.10\Softwares\Medusa 7.3\Setup_x64_7.3.0.194175\Setup_x64_7.3.0.194175.exe" -ArgumentList "/qb MLM_SERVER= 10.104.120.75 MLM_PORT=5033 MLTT_DEFAULT_CHECKOUT=5" -PassThru Start-Process -Wait -FilePath "\\10.30.35.10\Softwares\Medusa 7.4\Setup_x64_7.4.0.208020.exe" -ArgumentList "/q" -PassThru if ((Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Medusa") { Write-Host " Medusa is installed on System" -ForegroundColor Green sleep 10 if(Test-Path 'C:\Program Files\Medusa Labs\Test Tools\bin\') { Write-Host Path present Set-Path 'C:\Program Files\Medusa Labs\Test Tools\bin\' } Write-Host Environment variable set for Medusa path Set-Path 'C:\Program Files\Medusa Labs\Test Tools\bin\' } else { Write-Host " Failed to install Medusa on System" -ForegroundColor Red } } #Installing imdisk Write-Host "3.Checking if IMDisk is present on system" $instChk = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Imdisk" if ($instChk -ne $null) { Write-Host " Imdisk is already installed on system" -ForegroundColor Green } else { write-host " Installing Imdisk on system" -ForegroundColor Yellow Start-Process -Wait -FilePath \\10.30.35.10\softwares\ImDisk.exe -ArgumentList "/fullsilent" -PassThru if ((Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Imdisk") { write-Host " Imdisk successfully installed on system" -ForegroundColor Green } else { Write-Host " Failed to install IMDisk on system" -ForegroundColor Red } } #Installing wireshark #Latest wireshark download - #Invoke-WebRequest -Uri https://wireshark.marwan.ma/download/win64/Wireshark-win64-latest.exe -OutFile c:\Wireshark-win64-latest.exe Write-Host "4. Checking if Wireshark is present on system" if ((Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Wireshark") { Write-Host " Wireshark is already installed on system" -ForegroundColor DarkGreen Write-Host " Setting ENV variable path for Wireshark" -ForegroundColor Yellow [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Wireshark", [EnvironmentVariableTarget]::Machine) Write-Host " Installing vcredist" -ForegroundColor Yellow start-Process -Wait -FilePath "\\10.30.35.10\Softwares\Wireshark\vcredist_x64.exe" -ArgumentList "/install /quiet /norestart" } else { Write-Host " Installing WinPCap on system" -ForegroundColor Yellow Start-Process -FilePath "\\10.30.35.10\Softwares\Wireshark\winpcapsilent.exe" -ArgumentList "WinPcap*.exe" start-sleep 5 if (((Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "WinpCap")) { Write-Host " WinPCap successfully installed on system" -ForegroundColor Green } else { Write-Host " Failed on install WinPCap on system" -ForegroundColor Red } Write-Host "Installing Wireshark on system" -ForegroundColor Yellow Start-Process -Wait -FilePath "\\10.30.35.10\Softwares\Wireshark\Wireshark-win64-3.0.3.exe" -ArgumentList "/S" if ((Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -match "Wireshark") { Write-Host " Wireshark successfully installed on system" -ForegroundColor Green } else { Write-Host " Failed on install Wireshark on system" -ForegroundColor Red } Write-Host " Installing vcredist" -ForegroundColor Yellow start-Process -Wait -FilePath "\\10.30.35.10\Softwares\Wireshark\vcredist_x64.exe" -ArgumentList "/install /quiet /norestart" Write-Host " Setting ENV variable path for Wireshark" -ForegroundColor Green [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Wireshark", [EnvironmentVariableTarget]::Machine) Write-Host "Wireshark setup complete" -ForegroundColor Green } #Copying testsuite <# write-host "5.Checking testsuite folder on C:\" if (Test-Path "C:\testsuites") { write-host " TestSuite folder is already present on C:\" -ForegroundColor Green } else { Write-Host " Copying testsuite to C:\" -ForegroundColor Yellow if (Test-Connection "192.168.101.3" -Count 1 -Quiet) { Copy-Item -Path "\\192.168.101.3\Softwares\testsuites" -Destination c:\testsuites -Recurse -Force } else { Copy-Item -Path "\\10.30.35.10\Softwares\testsuites" -Destination c:\testsuites -Recurse -Force } } #> #Installing notepad++0 Install-NotepadPlusPlus #Installing device management module DeviceManagement #copying devcon get-devcon #Turn on OS debugger if ((Get-WmiObject -Class Win32_computersystem).model -ne "Virtual Machine") { debugOn } #Deleting network share Write-Host Deleting network share net use * /d /y $input = Read-host "Restart-Server ? (y/n) :" if ($input -eq 'y' ) { Restart-Computer } } ###################################################OS configuration related commands################################################### function Dis-SeverManagerOnStartup { #Disabling Server manager on start New-ItemProperty -Path "HKCU:\Software\Microsoft\ServerManager" -Name "DoNotOpenServerManagerAtLogon" -PropertyType DWORD -Value "0x1" -Force } function trustedItem { Set-Item WSMan:\localhost\Client\TrustedHosts "*" -Force Get-Item WSMan:\localhost\Client\TrustedHosts -Verbose } function restartexplorer { taskkill /im explorer.exe /f explorer } function settime { Set-TimeZone -id "India Standard Time" } function hostfile { notepad C:\Windows\System32\drivers\etc\hosts } function clearEventLog { $path = 'c:\users\administrator\Documents\EventBackup' $a = Test-Path $path If (!$a) { new-item -ItemType Directory -Name Eventbackup -Path c:\users\administrator\Documents\ -Verbose } $time = get-date -Format G; $time = $time -replace '[/:]', '-' wevtutil.exe epl system $path\EventLogs-System-$time.evtx wevtutil.exe cl system Write-Host System events cleared. Event Backup file created at $path\eventLog-System-$time.evtx } Function Eventlogs ($MarvellOnly, $NewestCount, $RunOnPeerAsWell) { if($NewestCount) { if($MarvellOnly) { Write-Host Getting MARVELL SYSTEM EVENT LOGS Get-EventLog -LogName System -Source qe*, l2nd2 -Newest $NewestCount } else { Write-Host Getting SYSTEM EVENT LOGS of type Error and Warning only Get-EventLog -LogName System -EntryType Error, Warning -Newest $NewestCount } if($RunOnPeerAsWell) { Write-Host `nGetting System Event Logs from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Eventlogs -MarvellOnly $args[0] -NewestCount $args[1]} -ArgumentList $MarvellOnly, $NewestCount } } else { if($MarvellOnly) { Write-Host Getting MARVELL SYSTEM EVENT LOGS Get-EventLog -LogName System -Source qe*, l2nd2 } else { Write-Host Getting SYSTEM EVENT LOGS of type Error and Warning only Get-EventLog -LogName System -EntryType Error, Warning } if($RunOnPeerAsWell) { Write-Host `nGetting System Event Logs from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Eventlogs -MarvellOnly $args[0]} -ArgumentList $MarvellOnly } } } Function Check_Crash_Events { Get-EventLog -LogName System -Source BUGCHECK -Newest 5 | fl } function stop ($process_name) { taskkill /im $process_name'.exe' /f } function cred { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass } function corpInfo { Write-host "Ethernet adapter Corp3: Connection-specific DNS Suffix . : punelab.qlogic.com qlogic.org qlogic.com mv.qlogic.com av.na Description . . . . . . . . . . . : Microsoft Kernel Debug Network Adapter Physical Address. . . . . . . . . : 30-E1-71-52-4F-B0 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::e89b:70e4:912f:da92%6(Preferred) IPv4 Address. . . . . . . . . . . : 172.28.14.205(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.240.0 Lease Obtained. . . . . . . . . . : Tuesday, February 13, 2018 3:24:46 PM Lease Expires . . . . . . . . . . : Tuesday, February 13, 2018 5:26:04 PM Default Gateway . . . . . . . . . : 10.30.32.1 DHCP Server . . . . . . . . . . . : 10.30.32.10 DHCPv6 IAID . . . . . . . . . . . : 221307249 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-A0-37-67-30-E1-71-52-4F-B2 DNS Servers . . . . . . . . . . . : 10.35.2.11 10.30.32.10 NetBIOS over Tcpip. . . . . . . . : Enabled" } function Dis-InternetExplorerESC { $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force Stop-Process -Name Explorer -Force Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green } function Dis-UserAccessControl { Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Force Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green } function Set-Path ($path) { #deleting duplicate entries in path variable. Write-Host "Deleting duplicate entries in path variable." -ForegroundColor Yellow $CurrentPath = [Environment]::GetEnvironmentVariable('Path','Machine') $SplittedPath = $CurrentPath -split ';' $CleanedPath = $SplittedPath | Sort-Object -Unique $NewPath = $CleanedPath -join ';' [Environment]::SetEnvironmentVariable('Path', $NewPath,'Machine') if ($path -eq $null) { Write-host Please enter path using `"set-path `$path`" } else { if ((Test-Path $path) -eq $false) { Write-host Please enter existant path } else { #$env:path = $env:path + ';' + $path [Environment]::SetEnvironmentVariable("Path", $env:Path + "$path", [EnvironmentVariableTarget]::Machine) Write-Host "path set `n `n $env:path `n `n" } } } function maa* { Restart-Service maa* -Verbose } function MedusaIP ($addMetric,$addRoute, $removeMetric) { #Write-Host "10.67.98.122 `n route add 10.67.98.0 mask 255.255.240.0 10.30.32.1 -p `n dc5wp-lic01.marvell.com" <#if ($addRoute) { route change 0.0.0.0 mask 0.0.0.0 10.30.32.1 metric 1 -p; route add 10.67.98.0 mask 255.255.128.0 10.30.32.1 -p; }#> if($addMetric) { Write-Host Setting interface metric to 1 for corp interface Set-NetIPInterface -InterfaceIndex (corpip).InterfaceIndex -InterfaceMetric 1 -Verbose } if($removeMetric) { Write-Host Setting interface metric to 0 for corp interface Set-NetIPInterface -InterfaceIndex (corpip).InterfaceIndex -InterfaceMetric 0 -Verbose } Set-Clipboard "10.67.98.122" -Verbose Write-Host Medusa IP 10.67.98.122 copied to clipboard Ping 10.67.98.122; ping dc5wp-lic01.marvell.com; } #Else try netsh int set interface 138 metric=1 function autologon { Write-Host Setting AutoAdminLogon New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name AutoAdminLogon -PropertyType STRING -Value 1 -ErrorAction SilentlyContinue New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultUserName -PropertyType STRING -Value Administrator -ErrorAction SilentlyContinue New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultPassword -PropertyType STRING -Value Qlogic01 -ErrorAction SilentlyContinue Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name AutoAdminLogon -Value 1 -ErrorAction SilentlyContinue Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultUserName -Value Administrator -ErrorAction SilentlyContinue Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultPassword -Value Qlogic01 -ErrorAction SilentlyContinue <# Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name AutoAdminLogon Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultUserName Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\' -Name DefaultPassword #> } function OsOnPartitions { $a = bcdedit $b = ($a) | Select-String OSDevice $c = ($a) | Select-String Identifier $i = 1 Foreach ($temp in $b) { $s = [String]$temp $driverLetter = $s.Substring($s.Length - 2, 1) #$a = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name * #$ProductVersion = $a.CurrentMajorVersionNumber + "." + $a.CurrentMinorVersionNumber + "." + $a.CurrentBuild + "." + $a.UBR $ProductVersion = (get-item $driverLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #Rename drive volume name in explorer label $driverLetter":" $ProductVersion #change bcdedit description $identifier = [String]$c[$i] $identifier = $identifier.Substring($identifier.IndexOf('{')) bcdedit /set $identifier description $ProductVersion $i++; } #Printing the output $a = bcdedit $b = ($a) | Select-String OSDevice, Identifier, Description $b } function Find-File { $FileToSearch } { } # Create C:\Startup.ps1 and startup.bat in startup path. Write anything you need at startup in startup.ps1 which will be opened in Powershell_ISE function Set-Startup { #Encoding param is veruy necessary here otherwise the batch file wont execute as it would contain garbage characters. Set-Content -Encoding ascii -Value "Powershell -File C:\Startup.ps1" -Path "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\startup.bat" if(!(Test-Path c:\Startup.ps1)){New-Item -Path C:\Startup.ps1 -Force} Write-host `n Opening Startup.ps1 in Powershell ISE, edit whatever required in startup -ForegroundColor Yellow Powershell_ise.exe -File c:\Startup.ps1 } #Check VM crash event on host function VmCrashEvent ($clearEvents) { #Event on host when VM is crashed, check this <# Critical 2/25/2020 11:40:31 AM Hyper-V-Worker 18590 None 'VM-9' has encountered a fatal error. The guest operating system reported that it failed with the following error codes: ErrorCode0: 0xD1, ErrorCode1: 0xFFFFA101FFDEC010, ErrorCode2: 0x2, ErrorCode3: 0x0, ErrorCode4: 0x0. If the problem persists, contact Product Support for the guest operating system. (Virtual machine ID 93B7774F-74BC-4744-AD4B-90E930F9739A) Guest message: Test bug check event in VMs using all-vms #> Get-WinEvent -ProviderName Microsoft-Windows-Hyper-V-Worker | Where-Object -Property ID -eq 18590 if($clearEvents) { wevtutil.exe cl Microsoft-Windows-Hyper-V-Worker-Operational } } #Disable automatic reboot option function Dis-AutoReboot { #Disable/Enable Automatic Reboot Get-WmiObject -Class Win32_OSRecoveryConfiguration -EnableAllPrivileges | Set-WmiInstance -Arguments @{ AutoReboot=$false } #Chech if its set (Get-WmiObject -Class Win32_OSRecoveryConfiguration).AutoReboot } #Disable automatic reboot option function En-AutoReboot { #Disable/Enable Automatic Reboot Get-WmiObject -Class Win32_OSRecoveryConfiguration -EnableAllPrivileges | Set-WmiInstance -Arguments @{ AutoReboot=$true } #Chech if its set (Get-WmiObject -Class Win32_OSRecoveryConfiguration).AutoReboot } #Sometimes copy paste doesnt work in remote sessions from your host/laptop. In this case this function will restart the clipboard service on remote server. function Clipboard-Service-Restart { #WS2019 Restart-Service cbdhsvc_43567 -Verbose #WS2016 stop rdpclip Write-Host Now Reconnect the server and copy paste should work } #Open the current directory in explorer function OpenExplorer { Get-Location | Invoke-Item } #for CQ path function LinuxPathToWindows ($LinuxPath) { $windowsPath = $LinuxPath.Replace("/","\").Replace("\usr\qlc","\\qlogic.org") $windowsPath Set-Clipboard $windowsPath Write-Host Path copied in clipboard ii $windowsPath } #Get/Set OS PageFileSize, function needs modification function PageFile ($sizeInMB) { # PowerShell Script to set the size of pagefile.sys $computersys = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges; $computersys.AutomaticManagedPagefile = $False; $computersys.Put(); $pagefile = Get-WmiObject -Query "Select * From Win32_PageFileSetting Where Name like '%pagefile.sys'"; if ($sizeInMB) { $pagefile.InitialSize = $sizeInMB; $pagefile.MaximumSize = $sizeInMB; $pagefile.Put(); } else { Write-Host PageFile Size is $PageFile } } function Install-NotepadPlusPlus { #Installing Notepad++ Start-Process (Get-ChildItem \\10.30.35.10\Softwares\*npp*.exe)[0].FullName -ArgumentList "/S" } function DeviceManagement { Write-Host Installing DeviceManagement Module Copy-Item '\\10.30.35.10\Softwares\DeviceManagement' -Destination 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules' -Force -Recurse #Copy-Item '\\10.30.35.10\Softwares\DeviceManagement' -Destination 'C:\Program Files\WindowsPowerShell\Modules' -Force -Recurse } function get-devcon { Write-Host Copying devcon.exe to C:\Windows\System32 Copy-Item \\10.30.35.10\Softwares\devcon.exe C:\Windows\System32 -Verbose } function CopyToStartup($path) { Copy-Item "$path" "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" -Verbose } function startup { ii "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" -ErrorAction SilentlyContinue } function MPIO { Get-WindowsFeature -Name MultiPath-IO $a = Get-WindowsFeature -Name MultiPath-IO | select installed if ($a -match 'False') { Write-Host `n MPIO Feature is not installed.... -Foregroundcolor "RED" $input = Read-Host -Prompt 'Would you like to install [yes/no]' if (($input -eq 'yes') -or ($input -eq 'y')) { Install-WindowsFeature -Name 'MultiPath-IO' } } } function noMPIO { Remove-WindowsFeature 'MultiPath-IO' } function nofirewall { netsh advfirewall set allprofiles state off } function noAutoUpdates { } function RAMUsage { $osInfo = Get-Ciminstance Win32_OperatingSystem $totalRAM = [math]::round($osInfo.TotalVisibleMemorySize / 1024 / 1024) $freeRAM = [math]::round($osInfo.FreePhysicalMemory / 1024 / 1024) $usedRAM = $totalRAM - $freeRAM Write-Host "TOTAL RAM `t $totalRAM GB `n USED RAM `t $usedRAM GB `n FREE RAM `t $freeRAM GB" } #This will set boot mode to safe boot, and a runonce registry to unset safe boot function nextBootToSafeMode { cmd /c "bcdedit /set {current} safeboot minimal" #Use * in Name to force executing in safe mode Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Name "*UnsetSafeBoot" -Value "cmd /k `"bcdedit /deletevalue {current} safeboot`"" Write-Host Added registry to unset safe boot after booting once.. } ###################################################OS configuration related commands Ends################################################### ####################General and Lab related################ function get ($SoftwareName) { $path = 'c:\Softwares' $a = Test-Path $path If (!$a) { new-item -ItemType Directory -Name Softwares -Path C:\ -Verbose } $a = Get-ChildItem -Path "\\10.30.35.10\Softwares\" -Name if ($SoftwareName.Length -eq 0) { for ($i = 1; $i -le $a.Count; $i++) { Write-Host $i. $a[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $a[$itemNumber - 1] $status = Copy-Item -Path "\\10.30.35.10\Softwares\$item" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } Else { $query = $a -match $SoftwareName If ($query.Length -eq 0) { Write-Host No item found with the given Name - $SoftwareName } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $status = Copy-Item -Path "\\10.30.35.10\Softwares\$item" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } else { $status = Copy-Item -Path "\\10.30.35.10\Softwares\$query" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } } } } function get-Script ($ScriptName) { $path = 'c:\' $a = Test-Path $path If (!$a) { new-item -ItemType Directory -Name Softwares -Path C:\ -Verbose } $a = Get-ChildItem -Path "\\10.30.35.10\Softwares\Sagar\Scripts" -Name if ($ScriptName.Length -eq 0) { for ($i = 1; $i -le $a.Count; $i++) { Write-Host $i. $a[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $a[$itemNumber - 1] $status = Copy-Item -Path "\\10.30.35.10\Softwares\Sagar\Scripts\$item" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } Else { $query = $a -match $ScriptName If ($query.Length -eq 0) { Write-Host No item found with the given Name - $ScriptName } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $status = Copy-Item -Path "\\10.30.35.10\Softwares\Sagar\Scripts\$item" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } else { $status = Copy-Item -Path "\\10.30.35.10\Softwares\Sagar\Scripts\$query" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path; ii $path -ErrorAction SilentlyContinue } Else { Write-Host Copy Failed..!!! } } } } } #get diskspd and copy to system32 function get-diskspd { $path = 'c:\windows\system32' $status = Copy-Item -Path "\\10.30.35.10\Softwares\Diskspd-v2.0.17\amd64fre\diskspd.exe" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied $item to $Path } Else { Write-Host Copy Failed..!!! } } <# Peer IP is the IP of the remote system where you run the NIC, RDMA traffic The below function sets that IP and saves in a file for persistant access to peer #> function Set-PeerIp ($ip) { $location="C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MarvellFastlinqCmdlets\MarvellFastlinq_PeerIP.txt" $ip > $location } #Displays the peerIP which was set using the Set-PeerIp Command function Get-PeerIp { $path = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MarvellFastlinqCmdlets\MarvellFastlinq_PeerIP.txt" if (!(Test-Path $path) -or ((Get-Content $path) -eq $null)) { Set-PeerIp (Read-Host -Prompt "Peer IP is not set, Please enter Peer IP: ") } $location = "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MarvellFastlinqCmdlets\MarvellFastlinq_PeerIP.txt" Get-Content $location } #Get Remote systems Marvell adapters IP address and pings them all Function Ping-Peer ($MTUSize) { if ((Get-PeerIp) -eq $null) { Set-PeerIp (Read-Host -Prompt "Peer IP is not set, Please enter Peer IP: ") } Write-Host "Getting peer ip addresses" $peerIpList = Invoke-Command -Authentication Negotiate -ComputerName (Get-PeerIp) -Command { (Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *Mellanox*, *hyper-v* | Where-Object -Property Status -eq "Up" |Where-Object LinkSpeed -ne "100 Mbps" | Where-Object LinkSpeed -ne "1 Gbps") | % { #Checking if IPV4 binding is enabled like in case of Hyper-V PF wont have the bindings if(((Get-NetAdapterBinding -ComponentID ms_tcpip -InterfaceAlias $_.InterfaceAlias).Enabled) -eq $true) { (Get-NetIPAddress -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue -AddressFamily IPv4).IPAddress } }#For-each } -Credential $cred #Command if($MTUSize) { foreach ($port in $peerIpList) { PING.EXE $port -l $MTUSize -f } } else { foreach ($port in $peerIpList) { PING.EXE $port } } } Function Ping-PeerV6 { if ((Get-PeerIp) -eq $null) { Set-PeerIp (Read-Host -Prompt "Peer IP is not set, Please enter Peer IP: ") } Write-Host "Getting peer ip addresses" $peerIpList = Invoke-Command -Authentication Negotiate -ComputerName (Get-PeerIp) -Command { (Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *Mellanox*, *hyper-v* | Where-Object -Property Status -eq "up" |Where-Object LinkSpeed -ne "100 Mbps" | Where-Object LinkSpeed -ne "1 Gbps") | % { #Checking if IPV6 binding is enabled like in case of Hyper-V PF wont have the bindings if(((Get-NetAdapterBinding -ComponentID ms_tcpip6 -InterfaceAlias $_.InterfaceAlias).Enabled) -eq $true) { (Get-NetIPAddress -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -ErrorAction SilentlyContinue | Where-Object PrefixOrigin -EQ "Manual").IPAddress } }#For-each } -Credential $cred #Command foreach ($port in $peerIpList) { PING.EXE $port } } function PeerShare { ii \\$(Get-PeerIp)\c$ } #Login to QIDL switches function SSH-Switch { param( [ValidateSet( "Arista-100G-7060X","Arista-RJ45-7050T", "Dell-Z9100", "Oxygen-Cisco-5010-1","Oxygen-Cisco-5010-2","Oxygen-HP2408-Brocade-8000", "Francium-Cisco-5548","Francium-HP2408-Brocade-8000", "Gold-Cisco-5020", "Radium-Cisco-5696-40G","Radium-Cisco-5548","Radium-Cisco-5010", "Silver-Cisco-5020" )] $SwitchName, $SwitchIp="", $Display_Switch_Cascade_Layout #$ShowSwitchCascadeLayout ) switch ($SwitchName) { "PAM4-L5-L6Rack" {$SwitchIp = "10.30.37.125"; break;} "Arista-100G-7060X" {$SwitchIp = "10.30.32.122"; break;} "Arista-RJ45-7050T" {$SwitchIp = "10.30.32.123"; break;} "Arista-Cisco-5000" {$SwitchIp = "10.30.32.135"; break;} "Arista-Brocade" {$SwitchIp = "10.30.32.124"; break;} "Dell-Z9100" {$SwitchIp = "10.30.32.121"; break;} "Oxygen-Cisco-5010-1" {$SwitchIp = "10.30.32.111"; break;} "Oxygen-Cisco-5010-2" {$SwitchIp = "10.30.32.112"; break;} "Oxygen-HP2408-Brocade-8000" {$SwitchIp = "10.30.32.113"; break;} "Francium-Cisco-5548" {$SwitchIp = "10.30.32.114"; break;} "Francium-HP2408-Brocade-8000" {$SwitchIp = "10.30.32.115"; break;} "Gold-Cisco-5020" {$SwitchIp = "10.30.32.116"; break;} "Radium-Cisco-5696-40G" {$SwitchIp = "10.30.32.117"; break;} "Radium-Cisco-5548" {$SwitchIp = "10.30.32.118"; break;} "Radium-Cisco-5010" {$SwitchIp = "10.30.32.119"; break;} "Silver-Cisco-5020" {$SwitchIp = "10.30.32.120"; break;} } if($Display_Switch_Cascade_Layout) { Start-Process -FilePath \\10.30.35.10\Softwares\Switch_Cascade_Layout.png } if($SwitchName) { Write-Host Logging to $SwitchName using IP $SwitchIp -ForegroundColor Yellow ssh.exe admin@$SwitchIp } } #####################General and Lab Related Command ends##################### ######################Device Related##################### function Rename-Interfaces ($NPAR) { #go to CreateVswicthesNPAR.ps1 and create vswitches using functions #also create corpswitch here. noHiddenDevices $i = 1; if ($NPAR) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { $deviceNumber = (Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).device; $functionNumber = (Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).function; $name = "D" + $deviceNumber + "P" + $functionNumber Rename-NetAdapter -Name $_.InterfaceAlias -NewName "$name" -Verbose } } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { $functionNumber = [int](Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).function; $functionNumber++; Rename-NetAdapter -Name $_.InterfaceAlias -NewName P$functionNumber -Verbose } } } #implement/call this function to get devices, have to be careful as some functions needs to run on disconnected/disabled devices while some cant run on these function get-Devices { (Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -ne '100 Mbps' | Where-Object -Property LinkSpeed -ne '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps' } <# https://docs.microsoft.com/en-us/previous-versions/ms803962(v=msdn.10)?redirectedfrom=MSDN The Network Interface performance object consists of counters that measure the rates at which bytes and packets are sent and received over a TCP/IP connection. It includes counters that monitor connection errors. It says TCP/IP so I assume that it is similar to what netstat -p tcp discards shows. Packets Outbound Discarded Shows the number of outbound packets to be discarded even though no errors had been detected to prevent transmission. One possible reason for discarding the a packet could be to free up buffer space. PERF_COUNTER_RAWCOUNT Packets Outbound Errors Shows the number of outbound packets that could not be transmitted because of errors. PERF_COUNTER_RAWCOUNT Packets Received Discarded Shows the number of inbound packets that were chosen to be discarded even though no errors had been detected to prevent their being deliverable to a higher-layer protocol. One possible reason for discarding such a packet could be to free up buffer space. PERF_COUNTER_RAWCOUNT Packets Received Errors Shows the number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol. PERF_COUNTER_RAWCOUNT https://kb.vmware.com/s/article/2039495 According to this, Packet loss when running high traffic burst could be due small rx tx buffers, increasing these rings will help. #> function Check-Discards ($maxSamples, $RunOnPeerAsWell) { $devices = get-Devices #with #0 index it will work on only one adapter and not multiple if the device strings are different $deviceString = [string](($devices.InterfaceDescription)[0] -replace '/','_') if ($deviceString -match '#') { $deviceString = $deviceString.Substring(0,$deviceString.IndexOf('#')).TrimEnd() } $counter = @("\Network Adapter($deviceString*)\Packets Received Discarded","\Network Adapter($deviceString*)\Packets Outbound Discarded") Get-Counter -Counter $counter -MaxSamples $maxSamples | ForEach { $_.CounterSamples | ForEach { [pscustomobject]@{ TimeStamp = $_.TimeStamp Path = $_.Path #Path = $_.InstanceName Value = $_.CookedValue } } Write-Host `n } if($RunOnPeerAsWell) { Write-Host `nChecking discards on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Check-Discards -MaxSamples $args[0]} -ArgumentList ($maxSamples) } }#function #> function Check-Discards2 ($maxSamples, $RunOnPeerAsWell) { $devices = get-Devices #with #0 index it will work on only one adapter and not multiple if the device strings are different $deviceString = [string](($devices.InterfaceDescription)[0] -replace '/','_') if ($deviceString -match '#') { $deviceString = $deviceString.Substring(0,$deviceString.IndexOf('#')).TrimEnd() } $counter = @("\Network Adapter($deviceString*)\Packets Received Discarded","\Network Adapter($deviceString*)\Packets Outbound Discarded") Get-Counter -Counter $counter -MaxSamples $maxSamples | ForEach { $_.CounterSamples | ForEach { [pscustomobject]@{ TimeStamp = $_.TimeStamp Path = $_.Path #Path = $_.InstanceName Value = $_.CookedValue } $prevValue = $_.CookedValue } Write-Host `n } if($RunOnPeerAsWell) { Write-Host `nChecking discards on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Check-Discards -MaxSamples $args[0]} -ArgumentList ($maxSamples) } }#function function Check-RSCStats ($maxSamples, $RunOnPeerAsWell) { $devices = get-Devices #with #0 index it will work on only one adapter and not multiple if the device strings are different $deviceString = [string](($devices.InterfaceDescription)[0] -replace '/','_') if ($deviceString -match '#') { $deviceString = $deviceString.Substring(0,$deviceString.IndexOf('#')).TrimEnd() } $counter = @("\Network Adapter($deviceString*)\TCP Active RSC Connections","\Network Adapter($deviceString*)\TCP RSC Average Packet Size","\Network Adapter($deviceString*)\TCP RSC Coalesced Packets/sec","\Network Adapter($deviceString*)\TCP RSC Exceptions/sec") Get-Counter -Counter $counter -MaxSamples $maxSamples | ForEach { $_.CounterSamples | ForEach { [pscustomobject]@{ TimeStamp = $_.TimeStamp Path = $_.Path #Path = $_.InstanceName Value = $_.CookedValue } } Write-Host `n } if($RunOnPeerAsWell) { Write-Host `nChecking discards on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Check-RSCStats -MaxSamples $args[0]} -ArgumentList ($maxSamples) } }#function function Check-Discards ($maxSamples, $RunOnPeerAsWell) { $devices = get-Devices #with #0 index it will work on only one adapter and not multiple if the device strings are different $deviceString = [string](($devices.InterfaceDescription)[0] -replace '/','_') if ($deviceString -match '#') { $deviceString = $deviceString.Substring(0,$deviceString.IndexOf('#')).TrimEnd() } $counter = @("\Network Adapter($deviceString*)\Packets Received Discarded","\Network Adapter($deviceString*)\Packets Outbound Discarded") Get-Counter -Counter $counter -MaxSamples $maxSamples | ForEach { $_.CounterSamples | ForEach { [pscustomobject]@{ TimeStamp = $_.TimeStamp Path = $_.Path #Path = $_.InstanceName Value = $_.CookedValue } } Write-Host `n } if($RunOnPeerAsWell) { Write-Host `nChecking discards on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Check-Discards -MaxSamples $args[0]} -ArgumentList ($maxSamples) } }#function function Check-TCPRetransmissions ($maxSamples) { Write-Host Getting TCP Segments Retransmitted Per Second `n`n -BackgroundColor CYAN for($i=1; $i -le $maxSamples; $i++) { $sut = netstat -s $peer = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock {netstat -s} #foreach ($b in $a){Write-Host $b $i; $i++} $tcpv4_retrans = [int](($sut[90] -split '=')[1]).trim() $tcpv6_retrans = [int](($sut[101] -split '=')[1]).trim() $peer_tcpv4_retrans = [int](($peer[90] -split '=')[1]).trim() $peer_tcpv6_retrans = [int](($peer[101] -split '=')[1]).trim() Write-Host "TCP IPv4 Seg. Rtrns: " -NoNewLine Write-Host $tcpv4_retrans -NoNewLine -ForegroundColor Red Write-Host "`t TCP IPv6 Seg. Rtrns: " -NoNewline Write-Host $tcpv6_retrans -ForegroundColor Yellow -NoNewline Write-Host "`t Peer TCP IPv4 Seg. Rtrns: " -NoNewLine Write-Host $peer_tcpv4_retrans -NoNewLine -ForegroundColor Red Write-Host "`t Peer TCP IPv6 Seg. Rtrns: " -NoNewline Write-Host $peer_tcpv6_retrans -ForegroundColor Yellow sleep 1 } }#function function Check-TCPRetransmissions-2 ($maxSamples) { Write-Host Getting TCP Segments Retransmitted Per Second `n`n -BackgroundColor RED for($i=1; $i -le $maxSamples; $i++) { $sut = netstat -s $peer = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock {netstat -s} #foreach ($b in $a){Write-Host $b $i; $i++} $tcpv4_retrans = [int](($sut[90] -split '=')[1]).trim() $tcpv6_retrans = [int](($sut[101] -split '=')[1]).trim() $peer_tcpv4_retrans = [int](($peer[90] -split '=')[1]).trim() $peer_tcpv6_retrans = [int](($peer[101] -split '=')[1]).trim() sleep 1 $sut2 = netstat -s $peer2 = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock {netstat -s} #foreach ($b in $a){Write-Host $b $i; $i++} $tcpv4_retrans_2 = [int](($sut2[90] -split '=')[1]).trim() $tcpv6_retrans_2 = [int](($sut2[101] -split '=')[1]).trim() $peer_tcpv4_retrans_2 = [int](($peer2[90] -split '=')[1]).trim() $peer_tcpv6_retrans_2 = [int](($peer2[101] -split '=')[1]).trim() $final_tcpv4_retrans = $tcpv4_retrans_2 - $tcpv4_retrans $final_tcpv6_retrans = $tcpv6_retrans_2 - $tcpv6_retrans $final_peer_tcpv4_retrans = $peer_tcpv4_retrans_2 - $peer_tcpv4_retrans $final_peer_tcpv6_retrans = $peer_tcpv6_retrans_2 - $peer_tcpv6_retrans Write-Host "TCP IPv4 Seg. Rtrns: " -NoNewLine Write-Host $final_tcpv4_retrans -NoNewLine -ForegroundColor Red Write-Host "`t TCP IPv6 Seg. Rtrns: " -NoNewline Write-Host $final_tcpv6_retrans -ForegroundColor Yellow -NoNewline Write-Host "`t Peer TCP IPv4 Seg. Rtrns: " -NoNewLine Write-Host $final_peer_tcpv4_retrans -NoNewLine -ForegroundColor Red Write-Host "`t Peer TCP IPv6 Seg. Rtrns: " -NoNewline Write-Host $final_peer_tcpv6_retrans -ForegroundColor Yellow if($i % 20 -eq 0) {Write-Host `n`n} } }#function ######################Device Related End##################### ###################################################Device disable enable commands################################################### function Dis-FcoEMiniport { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #Get FCoE Devices Get-Device -Class GUID_DEVCLASS_SCSIADAPTER | Where-Object -Property Service -EQ qefcoe | % { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function En-FcoEMiniport { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #Get FCoE Devices Get-Device -Class GUID_DEVCLASS_SCSIADAPTER | Where-Object -Property Service -EQ qefcoe | % { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function Dis-iSCSIMiniport { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #Get FCoE Devices Get-Device -Class GUID_DEVCLASS_SCSIADAPTER | Where-Object -Property Service -EQ qeois | % { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function En-iSCSIMiniport { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #Get FCoE Devices Get-Device -Class GUID_DEVCLASS_SCSIADAPTER | Where-Object -Property Service -EQ qeois | % { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function Dis-VBD ($functionNumber, $RunOnPeerAsWell) { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } if(($functionNumber) -or ($functionNumber -eq 0)) { Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ qebdrv | Where-Object -Property LocationInfo -Match "function $functionNumber" | % { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } <# PS C:\EIT_Drivers\ediag\8.60.12.0> (Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ qebdrv).LocationInfo PCI bus 94, device 0, function 0 PCI bus 94, device 0, function 1 PCI bus 94, device 0, function 2 PCI bus 94, device 0, function 3 #> else { Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ qebdrv | % { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } if($RunOnPeerAsWell) { Write-Host `nDisabling VBD interfaces on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Dis-VBD -Function $args} -ArgumentList $functionNumber } } function En-VBD ($functionNumber, $RunOnPeerAsWell) { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } if(($functionNumber) -or ($functionNumber -eq 0)) { Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ qebdrv | Where-Object -Property LocationInfo -Match "function $functionNumber" | % { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } else { Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ qebdrv | % { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } if($RunOnPeerAsWell) { Write-Host `nEnabling VBD interfaces on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; En-VBD -Function $args} -ArgumentList $functionNumber } } function dvbd-evbd {Dis-VBD -functionNumber 0; Dis-VBD -functionNumber 1; En-VBD -functionNumber 0; En-VBD -functionNumber 1} function Dis-VBD-E3 { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #For E3 Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ ebdrv | % { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function En-VBD-E3 { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } #For E3 Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property Service -EQ ebdrv | % { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } function dis ($interfaceAlias, $RunOnPeerAsWell) { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } if($interfaceAlias) { Disable-NetAdapter -InterfaceAlias $interfaceAlias -Verbose -Confirm:0 } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, Qlogic*, *hyper*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Disable-NetAdapter -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } if($RunOnPeerAsWell) { Write-Host `nDisabling interfaces on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; dis -interfaceAlias $args[0]} -ArgumentList $interfaceAlias } } function en ($interfaceAlias,$RunOnPeerAsWell) { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } if($interfaceAlias) { Enable-NetAdapter -InterfaceAlias $interfaceAlias -Verbose -Confirm:0 } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, Qlogic*, *hyper*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Enable-NetAdapter -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } if($RunOnPeerAsWell) { Write-Host `nDisabling interfaces on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; en -interfaceAlias $args[0]} -ArgumentList $interfaceAlias } } function dis-NDIS { ((Get-NetAdapter -InterfaceDescription *Marvell*, Qlogic*, *25G*, *Qlogic*, HPE* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Disable-NetAdapter -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } function en-NDIS { ((Get-NetAdapter -InterfaceDescription *Marvell*, Qlogic*, *25G*, *Qlogic*, HPE* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Enable-NetAdapter -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } #Some devcon commands- helps in case we have multiple adapters in system function Dis-IntelAdapter { if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *154D*} function En-IntelAdapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe Enable *154D*;} function Dis-MLNXAdapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *15B3*;} function En-MLNXAdapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe Enable *15B3*;} function Dis-ChelsioAdapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *PCI\VEN_1425*;} function En-ChelsioAdapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe enable *PCI\VEN_1425*;} function Dis-E3Adapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *16A4*; devcon.exe disable *16A1*;} function En-E3Adapter {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe enable *16A4*; devcon.exe enable *16A1*;} <# If you have muliple Marvell adapters, then this will disable all other adapters except what you specify here You can just specify normal string, no need to provide *string*, like GiveMe 622 and it will enable Quick adapter and disables all other. #> function GiveMe ($string) { if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DeviceManagement')) { DeviceManagement } Get-Device -Class GUID_DEVCLASS_SYSTEM | Where-Object -Property InstanceId -like *PCI\VEN_1077* | % { if ($_.Name -match "$string") { Enable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose }else { Disable-Device -InstanceId $_.InstanceId -Confirm:0 -Verbose } } Enable-NetAdapter -InterfaceDescription "*$string*" -Verbose } <# In case you have BigBear and ArrowHead adapters in one system, BB will enable BigBear adapter and disable AH adapter#> function BB {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *8070*;devcon.exe disable *8084*;devcon.exe disable *8080*;devcon.exe enable *1656*;devcon.exe enable *1656*} function AH {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe disable *1656*;devcon.exe disable *1634*;devcon.exe enable *8070*;devcon.exe enable *8070*;devcon.exe enable *8084*;devcon.exe enable *8080*;devcon.exe enable *8084*;devcon.exe enable *8080*;} function devconrescan {if(!(Test-Path C:\Windows\System32\devcon.exe)){get-devcon} devcon.exe rescan } ###################################################E3 commands################################################### #Enable error recovery for E3 adapter uun registry function E3-enable-error-recovery-in-registry { #$a=@{} #((Get-PnpDevice -Class System | Where-Object -Property FriendlyName -Match hpe).FriendlyName) | %{ $_ -match '(\d+$)'; $a+=$Matches[1] } #Multiple strings in -match match #used service ebdrv for getting E3 devices ((Get-PnpDevice -Class System | Where-Object { $_.Service -eq "ebdrv" }).FriendlyName) | % { $parts = $_ -split '#'; #Format the number as 4 digit number $deviceNumber = '{0:d4}' -f [int]$parts[1] New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318}\$deviceNumber" -Name enable_error_recovery -PropertyType STRING -Value 1 -ErrorAction SilentlyContinue } Write-Host Reboot the system for the registry settings to take effect } function winedebug () { $path = 'C:\Softwares\winedebug_rel_x64_1.0.31' $a = Test-Path $path If (!$a) { Write-Host "Winediag not present `\n Copying" get winedebug } cd $path .\winedebug_x64 -b10eng } ###################################################E3 commands End################################################### ############################################################Hyper-V########################################################### ##################VSwitch################## function CorpSwitch { New-VMSwitch corp -NetAdapterName (corpip).Interfacealias } function Create-vSwitches ($EnableSriov, $NPAR) { #go to CreateVswicthesNPAR.ps1 and create vswitches using functions #also create corpswitch here. $i = 1; if ($NPAR) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -ne "Disabled") | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { $deviceNumber = (Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).device; $functionNumber = (Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).function; $name = "D" + $deviceNumber + "P" + $functionNumber New-VMSwitch "$name" -NetAdapterName $_.InterfaceAlias -EnableIov $EnableSriov -Verbose } } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -ne "Disabled") | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { $functionNumber = [int](Get-NetAdapterHardwareInfo -InterfaceAlias $_.InterfaceAlias).function; $functionNumber++; New-VMSwitch P$functionNumber -NetAdapterName $_.InterfaceAlias -EnableIov $EnableSriov -Verbose } } } #Remove VMSwitch function noVMSwitch { Remove-VMSwitch P* -Confirm:0 -Verbose -Force Remove-VMSwitch SET* -Confirm:0 -Verbose -Force } function addmos ($SwitchName, $Count) { #Add mananement OS VMnet Name to manage each individual mos vports better 1..$count | foreach { Add-VMNetworkAdapter -ManagementOS -Verbose -SwitchName $SwitchName } } function nomos ($SwitchName) { Set-VMSwitch -Name $SwitchName -AllowManagementOS 0 -Verbose } function mosvlan ($vlanid) { if($vlanid -or ($vlanid -eq 0)) { Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName p* -VlanId $vlanid -Access -Verbose Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName set* -VlanId $vlanid -Access -Verbose } else { Get-VMNetworkAdapterVlan -ManagementOS } } function vmvlan ($vlanid) { Set-VMNetworkAdapterVlan -Verbose -VlanId $vlanid -Access -VMName * -VMNetworkAdapterName NA* } #######################VSWITCH END################# function VMRAM ($RAMSizeInGB) { Set-VMMemory -VMName * -StartupBytes $RAMSizeInGB -Verbose } function VMMemory ($RAMSizeInGB) { VMRAM($RAMSizeInGB) } function Assign-IpInVm ($subnet, $last_octet, $interfacesPerVm) { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass #$subnet = 30 #$last_octet = 10 $vms = get-vm | Where-Object -Property State -eq "Running" $vmCount = [int](get-vm).Count foreach ($vm in $vms) { Write-Host Assigning IP to $vm.Name #if($_ -gt 1){$subnet = 22} #if($_ -gt 2){$subnet = 23} #if($_ -gt 3){$subnet = 24} Invoke-Command -VMName $vm.name -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; setip_lastoctet_vm $args[0] $args[1] Write-Host Completed IP assigment for $vm.Name getIpv4Addresses getIpv6Addresses } -Args $subnet, $last_octet $last_octet = $last_octet + $interfacesPerVm } } function All-VMs-AsJob ($command) { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($temp in $VMNames) { Write-host Firing command in $temp <# In Ws2012R2 invoke command with -VNName doesnt work $a=Get-VMNetworkAdapter -VMName $temp -VMNetworkAdapterName corp $ip= $a.IPAddresses -match "10.30*" $Session = New-PSSession -ComputerName $ip -Credential $cred Invoke-Command -Authentication Negotiate -ComputerName $ip #> Invoke-Command -VMName $temp -Credential $cred -ScriptBlock { Write-host Result from VM $args[1] -ForegroundColor white -BackgroundColor Red Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; powershell -command $args[0] } -Args $command,$temp -AsJob }#foreach Get-Job | Wait-Job -Timeout 300 -Verbose | Receive-Job } function All-VMs ($command) { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($temp in $VMNames) { Write-host Firing command in $temp Invoke-Command -VMName $temp -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; powershell -command $args } -Args $command }#foreach } function hostshare { #find the hostname of of the host machine from VM registry settings $HostName = (Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\").GetValue("Hostname") ii \\$HostName\c$ } function CopyToAllVMs() { param( $sourcePath, $FromAVmToAllOtherVms, $FromHostToAllVms, [Parameter(Mandatory = $true)] [ValidateSet("startup", "c:\")]$destinationPath ) $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass if ($destinationPath -eq "startup") { $destination = "$home" + "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" } else { $destination = "c:\" } if ($FromAVmToAllOtherVms) { #find the hostname of of the host machine from VM registry settings $HostName = (Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\").GetValue("Hostname") $VMNames = (get-vm -ComputerName $HostName | Where-Object -Property State -eq 'Running').Name } if($FromHostToAllVms) { $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name } foreach ($temp in $VMNames) { Write-host Copying to $temp Get-VMIntegrationService $temp | ? { -not($_.Enabled) } | Enable-VMIntegrationService -Verbose Copy-VMFile -Name $temp -SourcePath $sourcePath -Verbose -DestinationPath $destination -FileSource Host -Force }#foreach } function DeleteFromStartupOfAllVMs() { param( $filename, $FromAVmToAllOtherVms, $FromHostToAllVms ) $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass if ($FromAVmToAllOtherVms) { #find the hostname of of the host machine from VM registry settings $HostName = (Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\").GetValue("Hostname") $VMNames = (get-vm -ComputerName $HostName | Where-Object -Property State -eq 'Running').Name } if($FromHostToAllVms) { $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name } foreach ($temp in $VMNames) { Write-host Deleting $filename from $temp Invoke-Command -Authentication Negotiate -VMName $temp -ScriptBlock {Remove-item "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\$args"} -ArgumentList $filename -Credential $cred }#foreach } function CopyFromHostToAllVMs($filename) { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($temp in $VMNames) { Write-host Firing command in $temp Invoke-Command -Authentication Negotiate -VMName $temp -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; powershell -command $args } -Args $command }#foreach } function All-VMs-ChangeHostname () { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name if($hostname.Length -gt 10) { $hostname = (hostname).substring(0,10)} else { $hostname = hostname} $count = 1 foreach ($temp in $VMNames) { $vmhostname = $hostname + "-VM" + $count; Write-host Changing hostname of $temp to $vmhostname Invoke-Command -Authentication Negotiate -VMName $temp -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; powershell -command Rename-Computer $args -Force; } -Args $vmhostname $count++; }#foreach } function Rename-Vms ($prefix) { $username = 'Administrator'; $password = 'Qlogic01'; $pass = ConvertTo-SecureString -String $password -AsPlainText -Force; $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass Get-VM | Where-Object -Property State -eq "Running" | % { Write-Host $_.Name; Invoke-Command -VMId $_.Id -Credential $cred -ScriptBlock { $newName = $args[0] + $args[1] ; Rename-Computer -NewName $newName -Verbose; return $newName } -ArgumentList $prefix, $_.Name } } function Connect-Vms { (Get-VM | Where-Object State -eq "Running"| select Name) | % { Write-host connecting $_.Name; vmconnect.exe localhost $_.Name; sleep 2 } } function cvms {Connect-Vms} #Dont use this function, checkpoint fails when we try to create it parallelly on more than one VMs. Use Checkpoint-VM * to create checkpoints one by one. function Create-VmCheckpoint { Get-VM | where State -eq running | %{Start-Job -Command {Checkpoint-VM $args} -ArgumentList $_.VMName -Verbose} } function VMFullScreen { Set-ResolutionInVM 1024 768 } function Set-ResolutionInVM ($width, $height) { Set-DisplayResolution -Width $width -Height $height -Force | Out-Null } function Create-VMs { param( $count, $VHDPath, $path_to_vms="C:\VMs", $numberOfInterfacesPerVM, $numberOfPortsOnAdapter, $vswitchArray, $createCorpSwitch=0 ) $iter = $count / $NumberOfPortsOnAdapter; $loop_counter = 1 $vm_counter = 1 $switch_counter = 0 while ($counter -le $iter) { # Path to where Virtual Machine data will be stored $path_to_vms = "C:\VMs" #Remove-VM -Name sriov* -Force Remove-Item $path_to_vms -Force -Recurse # Create virtual machine folders $new_vm = "$path_to_vms\${vmprefix}-${i}" New-Item -Path $new_vm -ItemType "Directory" New-Item -Path "$path_to_vms\Virtual Hard Disks" -ItemType "Directory" # Path to Master/Parent VHD $parent_vhd = $VHDPath $vmprefix = "VM" #$partner_vmprefix="r620-4850" foreach ($i in $first_vm..$last_vm) { #For Different Ports if ($i -gt 1) { $vmSwitch = "P1" } if ($i -gt 2) { $vmSwitch = "P3" } if ($i -gt 3) { $vmSwitch = "P4" } # Create a vhd differencing disk $new_diff_vhd = "$path_to_vms\Virtual Hard Disks\" New-VHD -ParentPath $parent_vhd -Differencing -Path $new_diff_vhd\VHD_VM_$i.vhdx # Create the VM New-VM -VHDPath "$new_diff_vhd\VHD_VM_$i.vhdx" -Name "${vmprefix}-${i}" -Path "$path_to_vms" -SwitchName "$vmSwitch" -Generation 2 # Configure Dynamic Memory, CPU, and COM Port Set-VMMemory -VMName "${vmprefix}-${i}" -DynamicMemoryEnabled $false -StartupBytes 4GB # -MaximumBytes 2GB Set-VMProcessor -VMName "${vmprefix}-${i}" -Count 16 Set-VMComPort -VMName "${vmprefix}-${i}" -Number 1 -Path "\\.\pipe\${vmprefix}-${i}" Set-VMFirmware -VMName "${vmprefix}-${i}" -EnableSecureBoot Off #Set-VMNetworkAdapter -VMName "${vmprefix}-${i}" -IovQueuePairsRequested 8 -VrssEnabled $true #Network adapter Name Variable $j = 1 Add-VMNetworkAdapter -VMName "${vmprefix}-${i}" -SwitchName "$vmSwitch" -Name "NA-$j" $j++ Add-VMNetworkAdapter -VMName "${vmprefix}-${i}" -SwitchName "$vmSwitch" -Name "NA-$j" $j++ #Set-VMNetworkAdapter -VMName "${vmprefix}-${i}" -IovWeight 100 Add-VMNetworkAdapter -VMName "${vmprefix}-${i}" -SwitchName "corp" -Name "Corp" } $counter++ } } function IterationCounterForm { Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $plusButtonClick={ $count=[int]$label.Text $count++ $label.Text=$count } $minusButtonClick={ $count=[int]$label.Text $count-- $label.Text=$count } $form = New-Object System.Windows.Forms.Form $form.Text = 'Iteration Counter' $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = 'CenterScreen' $form.TopMost=$true $plusButton = New-Object System.Windows.Forms.Button $plusButton.Location = New-Object System.Drawing.Point(55,65) $plusButton.Size = New-Object System.Drawing.Size(100,50) $plusButton.Text = 'PLUS' #$plusButton.DialogResult = [System.Windows.Forms.DialogResult]::None #$form.Button = $plusButton $form.Controls.Add($plusButton) $minusButton = New-Object System.Windows.Forms.Button $minusButton.Location = New-Object System.Drawing.Point(160,65) $minusButton.Size = New-Object System.Drawing.Size(100,50) $minusButton.Text = 'MINUS' #$plusButton.DialogResult = [System.Windows.Forms.DialogResult]::None #$form.Button = $minusButton $form.Controls.Add($minusButton) $okButton = New-Object System.Windows.Forms.Button $okButton.Location = New-Object System.Drawing.Point(75,120) $okButton.Size = New-Object System.Drawing.Size(75,23) $okButton.Text = 'OK' $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $okButton $form.Controls.Add($okButton) $cancelButton = New-Object System.Windows.Forms.Button $cancelButton.Location = New-Object System.Drawing.Point(150,120) $cancelButton.Size = New-Object System.Drawing.Size(75,23) $cancelButton.Text = 'Cancel' $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $cancelButton $form.Controls.Add($cancelButton) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(280,60) $label.Font = [System.Drawing.Font]::new("Microsoft Sans Serif", 26, [System.Drawing.FontStyle]::Bold) $label.TextAlign=[System.Drawing.ContentAlignment]::TopCenter $label.ForeColor = "RED" $label.Text = 1 $form.Controls.Add($label) #ActionEvents $plusButton.Add_Click($plusButtonClick) $minusButton.Add_Click($minusButtonClick) $form.Topmost = $true $form.Add_Shown({$plusButton.Select()}) #################### $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $x = $label.Text Write-Host $x iteration Completed. } } ###################VHD######################## function Get-OsOnVHD ($VHDPath) { $DriveLetter = [string](Mount-VHD -Path "$VHDPath" -Passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter $DriveLetter = $DriveLetter.trim() #$DriveLetter=$DriveLetter[2] Write-Host Got Driver letter as - $DriveLetter #$a = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name * #$ProductVersion = $a.CurrentMajorVersionNumber + "." + $a.CurrentMinorVersionNumber + "." + $a.CurrentBuild + "." + $a.UBR $ProductVersion = (get-item $DriveLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion Write-Host OS = $ProductVersion Dismount-VHD -Path "$VHDPath" $VHDPath = Get-Item $VHDPath $newName = $ProductVersion + $VHDPath.Extension Rename-Item -Path $VHDPath -NewName $newName ii $VHDPath.DirectoryName #Search for all vhds #Get-PSDrive -PSProvider FileSystem #Get-ChildItem -Path c:\ -File *.vhdx -Recurse } function Update-VHD ($VHDPath, $UpdateFile) { $DriveLetter = [string](Mount-VHD -Path $VHDPath -Passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter $DriveLetter = $DriveLetter.trim() #$DriveLetter=$DriveLetter[2] #$ProductVersion = (get-item $DriveLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion $a = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name * $ProductVersion = $a.CurrentMajorVersionNumber + "." + $a.CurrentMinorVersionNumber + "." + $a.CurrentBuild + "." + $a.UBR Write-Host OS Version before update = $ProductVersion #install update in vhds dism /image:$DriveLetter":\" /add-package /packagepath:$UpdateFile $ProductVersion = (get-item $DriveLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion Write-Host OS Version After update = $ProductVersion Dismount-VHD -Path $VHDPath Rename-Item -Path $VHDPath -NewName $ProductVersion } function Get-DriversInVHD ($VHDPath) { $DriveLetter = [string](Mount-VHD -Path $VHDPath -Passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter $DriveLetter = $DriveLetter.trim() #$DriveLetter=$DriveLetter[2] #$ProductVersion=(get-item $DriveLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #Write-Host OS Version before update = $ProductVersion #Get drives from VHD (dism /image:$DriveLetter":\" /Get-Drivers /format:table) | Select-String qevbd, qend Dismount-VHD -Path $VHDPath } function Remove-DriversInVHD ($VHDPath) { $DriveLetter = [string](Mount-VHD -Path $VHDPath -Passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter $DriveLetter = $DriveLetter.trim() #$DriveLetter=$DriveLetter[2] #$ProductVersion=(get-item $DriveLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #Write-Host OS Version before update = $ProductVersion #Get drives from VHD $Drivers = (dism /image:$DriveLetter":\" /Get-Drivers /format:table) | Select-String qevbd, qend if ($Drivers) { Write-host Current Installed Drivers `n $Drivers $oemNames = $Drivers | % { [string]$temp = $_; $temp.Substring(0, $temp.IndexOf('.')) } $oemNames | % { Dism /Image:$DriveLetter":\" /Remove-Driver /Driver:$_.inf } #Getting drivers after uninstallation Write-host #By default the below command will get only out of box drivers and not inbox. To get all we have to (dism /image:$DriveLetter":\" /Get-Drivers /format:table) | Select-String qevbd, qend Dismount-VHD -Path $VHDPath } else { Write-Host No out of box drivers found in VHD.. Dismount-VHD -Path $VHDPath } } function Install-DriversInVHD { param( $VHDPath, $VBDVersion, $NDISVersion, [Parameter(Mandatory = $true)] [ValidateSet("retail", "checked")]$driverType # [ValidateSet("yes","no")]$Install_ex1_package ) $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd" -Name if (!($VBDVersion) -or !($NDISVersion)) { Write-Host "Please input VBD and NDIS driver versions (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" break; } Else { # if($Install_ex1_package -eq 'yes'){$package = 'qlgc_ex1'} # else{$package = 'qlgc'} $query = $a -match $VBDVersion If ($query.Length -eq 0) { Write-Host No VBD driver found with given Version - $VBDVersion -Foregroundcolor "RED" break; } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $VBDinfPath = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$item\qlgc\$driverType" + "_x86-64\qevbd.inf" } else { $VBDinfPath = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$query\qlgc\$driverType" + "_x86-64\qevbd.inf" } } #Check NDIS Drivers $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend" -Name if ($NDISVersion.Length -eq 0) { Write-Host "Please input NDIS driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { # if($Install_ex1_package -eq 'yes'){$package = 'qlgc_ex1'} # else{$package = 'qlgc'} $query = $a -match $NDISVersion If ($query.Length -eq 0) { Write-Host No NDIS driver found with given Version - $NDISVersion -Foregroundcolor "RED" break; } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $NDISinfPath = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$item\qlgc\$driverType" + "_x86-64\qend.inf" } else { $NDISinfPath = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$query\qlgc\$driverType" + "_x86-64\qend.inf" } } } #Drivers check is complete, now you can start mounting and installing VHD $DriveLetter = [string](Mount-VHD -Path $VHDPath -Passthru | Get-Disk | Get-Partition | Get-Volume).DriveLetter $DriveLetter = $DriveLetter.trim() #$DriveLetter=$DriveLetter[2] #Get drivers from VHD $Drivers = (dism /image:$DriveLetter":\" /Get-Drivers /format:table) | Select-String qevbd, qend Write-Host Current Installed VBD and NDIS version - Write-Host $Drivers #$oemNames = $Drivers | %{[string]$temp = $_; $temp.Substring(0,$temp.IndexOf('.'))} #$oemNames | %{ Dism /Image:$DriveLetter":\" /Remove-Driver /Driver:$_.inf} #Install drivers <# PS C:\EIT_Drivers\ediag\8.40.1.0> dism /image:G:\ /add-driver /driver:\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\8.40.36.0\qlgc\checked_x86-64\qevbd.inf /ForceUnsigned Deployment Image Servicing and Management tool Version: 10.0.17763.1 Image Version: 10.0.17763.194 Found 1 driver package(s) to install. Installing 1 of 1 - \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\8.40.36.0\qlgc\checked_x86-64\qevbd.inf: The driver package was successfully installed. The operation completed successfully. #> $VBDStatus = Dism /Image:$DriveLetter":\" /Add-Driver /Driver:"$VBDinfPath" /ForceUnsigned $NDISStatus = Dism /Image:$DriveLetter":\" /Add-Driver /Driver:"$NDISinfPath" /ForceUnsigned if ($VBDStatus -match "The driver package was successfully installed") { Write-Host `n; $VBDStatus; Write-Host VBD Driver installed successfully`n -Foregroundcolor "Green" } Else { Write-Host $VBDStatus `n VBD Driver installation failed..!!! -Foregroundcolor "RED" } if ($NDISStatus -match "The driver package was successfully installed") { Write-Host `n; $NDISStatus; Write-Host NDIS Driver installed successfully`n -Foregroundcolor "Green" } Else { Write-Host $NDISStatus `n NDIS Driver installation failed..!!! -Foregroundcolor "RED" } #Getting drivers after uninstallation Write-host Drivers after installation complete - #By default the below command will get only out of box drivers and not inbox. To get all we have to (dism /image:$DriveLetter":\" /Get-Drivers /format:table) | Select-String qevbd, qend Dismount-VHD -Path $VHDPath } #else } #function function Find-VHDs { $a = get-wmiobject Win32_LogicalDisk | ? { $_.drivetype -eq 3 } | % { get-psdrive $_.deviceid[0] } foreach ($b in $a) { Write-Host Searching in $b.root -ForegroundColor DARKGREEN #Simpler version Get-ChildItem -Path $b.root -File *.vhdx -Depth 2 #-Depth param doesnt work in W2012R2 #Complex Version #foreach($b in $a){ Get-ChildItem -Path $_.Name -File *.vhdx -Recurse -Depth 5} # Get-ChildItem -Path $b.root -File *.vhdx -Depth 3 # Get-ChildItem | ?{$_.Name -NotLike 'Program*' -and $_.Name -notlike 'windows*'} } } ###################VHD End######################## ###########################################################Hyper-V End########################################################### ###########################################SRIOV############################################################## New-Alias -Name sriov -Value Get-NetAdapterSriov New-Alias -Name vf -Value Get-NetAdapterSriovVf function vfCount { Write-host "`nTotal VFs : $((Get-NetAdapterSriovVf).count)" -ForegroundColor Yellow; Get-NetAdapterSriovVf | Group-Object -Property Name } function Dis-Sriov { Set-NetAdapterAdvancedProperty -DisplayName SR-IOV -DisplayValue Disabled -Verbose} function En-Sriov { Set-NetAdapterAdvancedProperty -DisplayName SR-IOV -DisplayValue Enabled -Verbose} function IOvQueuePairs { param( $value, $AssignToTurnedOffVmsAsWell=0 ) if($AssignToTurnedOffVmsAsWell){ get-vm | ForEach-Object{ Set-VMNetworkAdapter -Vmname $_.Name -IovQueuePairsRequested $value -Verbose }} else { get-vm | Where-Object -Property State -eq 'Running' | ForEach-Object{ Set-VMNetworkAdapter -Vmname $_.Name -IovQueuePairsRequested $value -Verbose }} } function IOVWeight ($value, $VMName, $VMNetworkAdapterName) { if ($VMName) { Set-VMNetworkAdapter -Vmname $VMName -IovWeight $value -Verbose } else { Set-VMNetworkAdapter -Vmname * -IovWeight $value -Verbose } } function Get-VF-Stats { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vfCounterAll = 0 $vfRxCounterAll = 0 $vfTxCounterAll = 0 $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($vmName in $vmNames) { Write-Host Getting VFs info from $vmName -BackgroundColor DARKGREEN <# In WS2012R2 the -VMName Param doesnt work in NewPSSession and hence we have to use -ComputerName instead like below code) $a=Get-VMNetworkAdapter -VMName $vmName -VMNetworkAdapterName corp $ip= $a.IPAddresses -match "10.30*" $Session = New-PSSession -ComputerName $ip -Credential $cred #> $Session = New-PSSession -VMName "$vmName" -Credential $cred $vfInfo = Invoke-Command -Session $Session -ScriptBlock { Get-NetAdapter -InterfaceDescription *Marvell*, *qlogic*, *hpe* | % { Write-host Checking stats for $_.Name $_.InterfaceDescription -ForegroundColor CYAN; $stats1 = Get-NetAdapterStatistics -Name $_.Name $rx1 = ($stats1).ReceivedBytes; $tx1 = ($stats1).SentBytes; Sleep 1; $stats2 = Get-NetAdapterStatistics -Name $_.Name $rx2 = ($stats2).ReceivedBytes; $tx2 = ($stats2).SentBytes; if (($rx2 -gt ($rx1 + 1000)) -ne 0) { $throughput = [math]::round((($rx2 - $rx1) / 1MB), 2); Write-Host Rx Throughput -NoNewLine; Write-Host - $throughput MBps -NoNewLine -ForegroundColor Magenta; Write-Host " Before $rx1 bytes After $rx2 bytes" -ForegroundColor DarkGray; $vfRxCounter++; } else { Write-Host NO Rx Traffic running -ForegroundColor RED } if (($tx2 -gt ($tx1 + 1000)) -ne 0) { $throughput = [math]::round((($tx2 - $tx1) / 1MB), 2); Write-Host Tx Throughput -NoNewLine; Write-Host - $throughput MBps -NoNewLine -ForegroundColor Magenta; Write-Host " Before $tx1 bytes After $tx2 bytes" -ForegroundColor DarkGray; $vfTxCounter++ } else { Write-Host NO Tx Traffic running -ForegroundColor RED } $vfcounter++; } #for each VMNIC Write-Host `nResult: Write-host Rx traffic running on $vfRxCounter`/$vfcounter VFs Write-Host Tx traffic running on $vfTxCounter`/$vfcounter VFs $arr = $vfRxCounter, $vfTxCounter, $vfcounter; return $arr } #scriptblock $vfRxCounterAll = $vfRxCounterAll + $vfInfo[0] $vfTxCounterAll = $vfTxCounterAll + $vfInfo[1] $vfCounterAll = $vfCounterAll + $vfInfo[2] #Write-host $VfInfo Remove-PSSession -Vmname vm-$_ -verbose $Session = "" $vfInfo = "" Write-Host "`nSo far, Out of " -NoNewLine; Write-host $vfCounterAll VFs -ForegroundColor Green -NoNewLine; Write-Host " Rx traffic was running on " -NoNewLine; Write-host $vfRxCounterAll VFs -ForegroundColor Cyan -NoNewLine; Write-host " and Tx traffic was running on " -NoNewLine; Write-host $vfTxCounterAll VFs`n -ForegroundColor Cyan }# foreach VM #Final VF Stats Write-Host "FINAL RESULT: `n Out of " -NoNewLine; Write-host $vfCounterAll VFs -ForegroundColor Green -NoNewLine; Write-Host " Rx traffic was running on " -NoNewLine; Write-host $vfRxCounterAll VFs -ForegroundColor Cyan -NoNewLine; Write-host " and Tx traffic was running on " -NoNewLine; Write-host $vfTxCounterAll VFs -ForegroundColor Cyan } function Get-VF-Status { <#Use this logic $sb = { param($vm,$cred) Invoke-Command -Authentication Negotiate -ScriptBlock { Write-Host $vm ; Get-PnpDevice -Class net -FriendlyName *4820* } -VMName $vm.Name -Credential $cred } $a | %{ Start-Job -ScriptBlock $sb -ArgumentList $_, $cred | Out-Null } Get-Job | Wait-Job | Receive-Job #> $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $totalVfCount = 0 #$vmCount=(get-vm).count $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($vmName in $vmNames) { Write-Host Getting VFs info from $vmName -BackgroundColor DARKGREEN <#Use this logic $sb = { param($vm,$cred) Invoke-Command -Authentication Negotiate -ScriptBlock { Write-Host $vm ; Get-PnpDevice -Class net -FriendlyName *4820* } -VMName $vm.Name -Credential $cred } $a | %{ Start-Job -ScriptBlock $sb -ArgumentList $_, $cred | Out-Null } Get-Job | Wait-Job | Receive-Job #> $Session = New-PSSession -VMName "$vmName" -Credential $cred $VfInfo = Invoke-Command -Session $Session -ScriptBlock { Get-NetAdapter -InterfaceDescription *Marvell*, *qlogic*, *hpe* | Select InterfaceDescription } #Write-host $VfInfo $totalVfCount = $totalVfCount + $VfInfo.Count Write-Host $VfInfo.Count VFs are created in $vmName -ForegroundColor YELLOW Write-Host Total VFs - $totalVfCount `n -ForegroundColor DARKGREEN Remove-PSSession -Vmname vm-$_ -verbose $Session = "" $VfInfo = "" } } function disable-enable-sriov-vmq-loop { Set-NetAdapterAdvancedProperty -DisplayName "Virtual Machine Queues" -DisplayValue Disabled -Verbose -InterfaceDescription qlogic*; Set-NetAdapterAdvancedProperty -DisplayName "SR-IOV" -DisplayValue Disabled -Verbose -InterfaceDescription qlogic*; sleep 30; Set-NetAdapterAdvancedProperty -DisplayName "Virtual Machine Queues" -DisplayValue Enabled -Verbose -InterfaceDescription qlogic*; Set-NetAdapterAdvancedProperty -DisplayName "SR-IOV" -DisplayValue Enabled -Verbose -InterfaceDescription qlogic*; sleep 30; Write-Host 'VF Count - ' + (VF).Count + ' VMQ Count - ' + (vmqq).count } ###########################################SRIOV End############################################################## ###############################################VMQ############################################################ New-Alias -Name vmq -Value Get-NetAdapterVmq New-Alias -Name vmqq -Value Get-NetAdapterVmqQueue function vmqCount { (Get-NetAdapterVmqQueue).count } function dis-vmq { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Disable-NetAdapterQos -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } function en-vmq { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Enable-NetAdapterQos -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } function Get-TrafficStatusOnVms { } function Get-Vmq-Status { <#Use this logic $sb = { param($vm,$cred) Invoke-Command -Authentication Negotiate -ScriptBlock { Write-Host $vm ; Get-PnpDevice -Class net -FriendlyName *4820* } -VMName $vm.Name -Credential $cred } $a | %{ Start-Job -ScriptBlock $sb -ArgumentList $_, $cred | Out-Null } Get-Job | Wait-Job | Receive-Job #> $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $totalVfCount = 0 #$vmCount=(get-vm).count $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($vmName in $vmNames) { Write-Host Getting VMQ info from $vmName -BackgroundColor DARKGREEN <#Use this logic $sb = { param($vm,$cred) Invoke-Command -Authentication Negotiate -ScriptBlock { Write-Host $vm ; Get-PnpDevice -Class net -FriendlyName *4820* } -VMName $vm.Name -Credential $cred } $a | %{ Start-Job -ScriptBlock $sb -ArgumentList $_, $cred | Out-Null } Get-Job | Wait-Job | Receive-Job #> $Session = New-PSSession -VMName "$vmName" -Credential $cred $VmqInfo = Invoke-Command -Session $Session -ScriptBlock { Get-NetAdapter | Where-Object LinkSpeed -ne '1 Gbps' | Where-Object LinkSpeed -ne '100 Mbps' | Select InterfaceDescription } #Write-host $VfInfo $totalVmqCount = $totalvmqCount + $VmqInfo.Count Write-Host $VmqInfo.Count VMQs are created in $vmName -ForegroundColor YELLOW Write-Host Total VMQs - $totalVmqCount `n -ForegroundColor DARKGREEN Remove-PSSession -Vmname vm-$_ -verbose $Session = "" $VfInfo = "" } } function Get-Vmq-Stats { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $vmqCounterAll = 0 $vmqRxCounterAll = 0 $vmqTxCounterAll = 0 $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($vmName in $vmNames) { Write-Host Getting VMQs info from $vmName -BackgroundColor DARKGREEN $Session = New-PSSession -VMName "$vmName" -Credential $cred $vmqInfo = Invoke-Command -Session $Session -ScriptBlock { Get-NetAdapter | Where-Object LinkSpeed -ne '1 Gbps' | Where-Object LinkSpeed -ne '100 Mbps' | % { Write-host Checking stats for $_.Name $_.InterfaceDescription -ForegroundColor CYAN; $stats1 = Get-NetAdapterStatistics -Name $_.Name $rx1 = ($stats1).ReceivedBytes; $tx1 = ($stats1).SentBytes; Sleep 1; $stats2 = Get-NetAdapterStatistics -Name $_.Name $rx2 = ($stats2).ReceivedBytes; $tx2 = ($stats2).SentBytes; if (($rx2 -gt ($rx1 + 1000)) -ne 0) { $throughput = [math]::round((($rx2 - $rx1) / 1MB), 2); Write-Host Rx Throughput -NoNewLine; Write-Host - $throughput MBps -NoNewLine -ForegroundColor Magenta; Write-Host " Before $rx1 bytes After $rx2 bytes" -ForegroundColor DarkGray; $vmqRxCounter++; } else { Write-Host NO Rx Traffic running -ForegroundColor RED } if (($tx2 -gt ($tx1 + 1000)) -ne 0) { $throughput = [math]::round((($tx2 - $tx1) / 1MB), 2); Write-Host Tx Throughput -NoNewLine; Write-Host - $throughput MBps -NoNewLine -ForegroundColor Magenta; Write-Host " Before $tx1 bytes After $tx2 bytes" -ForegroundColor DarkGray; $vmqTxCounter++ } else { Write-Host NO Tx Traffic running -ForegroundColor RED } $vmqcounter++; } #for each VMNIC Write-Host `nResult: Write-host Rx traffic running on $vmqRxCounter`/$vmqcounter VMQs Write-Host Tx traffic running on $vmqTxCounter`/$vmqcounter VMQs $arr = $vmqRxCounter, $vmqTxCounter, $vmqcounter; return $arr } #scriptblock $vmqRxCounterAll = $vmqRxCounterAll + $vmqInfo[0] $vmqTxCounterAll = $vmqTxCounterAll + $vmqInfo[1] $vmqCounterAll = $vmqCounterAll + $vmqInfo[2] #Write-host $VfInfo Remove-PSSession -Vmname vm-$_ -verbose $Session = "" $vmqInfo = "" Write-Host "`nSo far, Out of " -NoNewLine; Write-host $vmqCounterAll VMQs -ForegroundColor Green -NoNewLine; Write-Host " Rx traffic was running on " -NoNewLine; Write-host $vmqRxCounterAll VMQs -ForegroundColor Cyan -NoNewLine; Write-host " and Tx traffic was running on " -NoNewLine; Write-host $vmqTxCounterAll VMQs`n -ForegroundColor Cyan }# foreach VM #Final VMQ Stats Write-Host "FINAL RESULT: `n Out of " -NoNewLine; Write-host $vmqCounterAll VMQs -ForegroundColor Green -NoNewLine; Write-Host " Rx traffic was running on " -NoNewLine; Write-host $vmqRxCounterAll VMQs -ForegroundColor Cyan -NoNewLine; Write-host " and Tx traffic was running on " -NoNewLine; Write-host $vmqTxCounterAll VMQs -ForegroundColor Cyan } ###############################################VMQ End############################################################ #######################################VMMQ#################### function En-Vrss { Get-NetAdapterAdvancedProperty -DisplayName "*virtual Switch rss*" | % { Set-NetAdapterAdvancedProperty -DisplayName $_.DisplayName -DisplayValue Enabled -Verbose -InterfaceDescription $_.INterfaceDescription } } function Dis-Vrss { Get-NetAdapterAdvancedProperty -DisplayName "*virtual Switch rss*" | % { Set-NetAdapterAdvancedProperty -DisplayName $_.DisplayName -DisplayValue Disabled -Verbose -InterfaceDescription $_.INterfaceDescription } } function vPort { Get-NetAdapterVPort } function vPortCount { (Get-NetAdapterVPort).count } function vPortQpCount { vport | Measure-Object Qpairs -Sum } function MaxQueuePairsL2PerVport { param( [ValidateSet("Auto", "1", "2", "4", "8", "16")]$displayValue ) ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($displayValue) { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Max Queue Pairs (L2) Per VPort" -DisplayValue $displayValue -Verbose } else { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Max Queue Pairs (L2) Per VPort" } } } function Set-VmmqQueuePairsDefaultQueue ($value) { if ($value -eq 1) { Set-VMSwitch * -DefaultQueueVmmqEnabled 0 -DefaultQueueVmmqQueuePairs $value -Verbose } else { Set-VMSwitch * -DefaultQueueVmmqEnabled 1 -DefaultQueueVmmqQueuePairs $value -Verbose } } function Set-VmmqQueuePairsMos ($value) { if ($value -eq 1) { Set-VMNetworkAdapter -ManagementOS -VmmqEnabled 0 -VmmqQueuePairs $value -Verbose } else { Set-VMNetworkAdapter -ManagementOS -VmmqEnabled 1 -VmmqQueuePairs $value -Verbose } } function Set-VmmqQueuePairs ($value) { if ($value -eq 1) { Set-VMNetworkAdapter -Vmname * -VmmqEnabled 0 -VmmqQueuePairs $value -Verbose } else { Set-VMNetworkAdapter -Vmname * -VmmqEnabled 1 -VmmqQueuePairs $value -Verbose } } function nx2sh { get nx2sh C:\EIT_Drivers\Softwares\nx2sh\1.0.13.0\x64\Debug\nx2sh.exe } #######################################VMMQ End#################### ###########################################################Advanced Property########################################################### function JumboMtu ($jumbovalue, $RunOnPeerAsWell) { Write-Host `nSetting/Getting Jumbo MTU $jumbovalue on SUT`n -ForegroundColor Magenta if($jumbovalue) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Jumbo Packet" -DisplayValue $jumbovalue -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 }; ((Get-NetAdapter -InterfaceDescription *hyper-V* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($jumbovalue -eq 1514) { Set-NetAdapterAdvancedProperty -DisplayName "Jumbo Packet" -DisplayValue "Disabled" -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } else { Set-NetAdapterAdvancedProperty -DisplayName "Jumbo Packet" -DisplayValue "$jumbovalue bytes" -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-v* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Get-NetAdapterAdvancedProperty -DisplayName "Jumbo Packet" -InterfaceAlias $_.InterfaceAlias -Verbose}; } if($RunOnPeerAsWell) { Write-Host `nSetting/Getting Jumbo MTU $jumbovalue on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; JumboMtu -jumbovalue $args[0]} -ArgumentList ($jumbovalue) } } #VLAN function VLAN ($vlanid, $RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if($vlanid -or ($vlanid -eq 0)) {Set-NetAdapterAdvancedProperty -DisplayName "vlan id" -DisplayValue $vlanid -InterfaceAlias $_.InterfaceAlias -Verbose } else {Get-NetAdapterAdvancedProperty -DisplayName "vlan id" -InterfaceAlias $_.InterfaceAlias -Verbose} } if($RunOnPeerAsWell) { Write-Host `nSetting/Getting VLAN id $vlanid on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; VLAN $args[0]} -ArgumentList ($vlanid) } } #PriorityAndVLAN function PriorityAndVLAN { param( [ValidateSet("Priority & VLAN disabled", "Priority enabled", "VLAN enabled", "Priority & VLAN enabled")]$displayValue, $RunOnPeerAsWell ) if($displayValue) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Priority & VLAN" -DisplayValue $displayValue -Verbose } } else { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Priority & VLAN" } } if($RunOnPeerAsWell) { Write-Host `n Setting Priority and VLAN to $displayValue on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; if($args[0] -ne $null){PriorityAndVLAN -displayValue $args[0]} else {PriorityAndVLAN}} -ArgumentList ($displayValue) } } #RSSQueue function RSSQueues { param( [ValidateSet("2", "4", "8", "16")]$displayValue ) ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($displayValue) { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Maximum Number of RSS Queues" -DisplayValue $displayValue -Verbose } else { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "Maximum Number of RSS Queues" } } } #ReceiveBuffer function ReceiveBuffer ($displayValue){ ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($displayValue -or ($displayValue -eq 0)) { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -RegistryKeyword "*ReceiveBuffers" -DisplayValue $displayValue -Verbose } else { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -RegistryKeyword "*ReceiveBuffers" } } } #RXBuffer function RxBuffer ($displayValue) { ReceiveBuffer -displayValue $displayValue} #TXBuffer function TransmitBuffer ($displayValue){ ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($displayValue -or ($displayValue -eq 0)) { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -RegistryKeyword "*TransmitBuffers" -DisplayValue $displayValue -Verbose } else { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -RegistryKeyword "*TransmitBuffers" } } } function TxBuffer ($displayValue) { TransmitBuffer -displayValue $displayValue} function dis-RSC ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Recv Segment Coalescing*" -DisplayValue Disabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Disabling RSC on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; dis-RSC} } } function en-RSC ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Recv Segment Coalescing*" -DisplayValue Enabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Enabling RSC on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; en-RSC} } } function dis-RSS ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Receive Side Scaling" -DisplayValue Disabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Disabling RSS on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; dis-RSS} } } function en-RSS ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Receive Side Scaling" -DisplayValue Enabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Enabling RSS on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; en-RSS} } } function dis-LSO ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Large Send Offload V2 (IPv*" -DisplayValue Disabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Disabling RSS on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; dis-LSO} } } function en-LSO ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "Large Send Offload V2 (IPv*" -DisplayValue Enabled -InterfaceAlias $_.InterfaceAlias -Verbose } if($RunOnPeerAsWell) { Write-Host `n Enabling LSO on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; en-LSO} } } function dis-ptp { Set-NetAdapterAdvancedProperty -DisplayName ptp* -DisplayValue Disabled -Verbose } function en-ptp { Set-NetAdapterAdvancedProperty -DisplayName ptp* -DisplayValue Enabled -Verbose } function ptp { Get-NetAdapterAdvancedProperty -DisplayName ptp* } New-Alias -Name adapter -Value Get-NetAdapter New-Alias -Name devs -Value Get-NetAdapter New-Alias -Name rss -Value Get-NetAdapterRss New-Alias -Name rsc -Value Get-NetAdapterRsc New-Alias -Name lso -Value Get-NetAdapterLso New-Alias -Name cko -Value Get-NetAdapterChecksumOffload #Restore NetAdapter Advanced Properties function Restore-Default ($RunOnPeerAsWell) { $devices = get-Devices foreach ($device in $devices) { Write-Host Checking Non Default Values on $device.Name -ForegroundColor Magenta $prop= Get-NetAdapterAdvancedProperty $device.Name foreach ( $temp in $prop) { # Write-Host Current prop is ($temp).DisplayName -BackgroundColor Black # Write-Host Possible values are ($temp).ValidDisplayValues -BackgroundColor Blue if ($temp.DisplayName -ne "Locally Administered Address") { if($temp.DisplayName -ne "Network Address") { if($temp.DisplayValue -ne $temp.DefaultDisplayValue) { Write-Host "Current " -NoNewline Write-Host $temp.DisplayName -ForegroundColor Cyan -NoNewline Write-Host " is set to " -NoNewline Write-Host $temp.DisplayValue -NoNewline -ForegroundColor Red Write-Host "`t`t Setting it to default " -NoNewline Write-Host $temp.DefaultDisplayValue -ForegroundColor Green Set-NetAdapterAdvancedProperty -InterfaceAlias $device.InterfaceAlias -DisplayName $temp.DisplayName -DisplayValue $temp.DefaultDisplayValue } }#if NetworkAddress }#if LAA } #Prop For each Write-Host `n`n }#Device For Each if($RunOnPeerAsWell) { Write-Host `nRestoring default on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Restore-Default} } }#function function Set-Default ($RunOnPeerAsWell) { Restore-Default -RunOnPeerAsWell $RunOnPeerAsWell } function Get-NonDefaultValues ($RunOnPeerAsWell) { $devices = get-Devices foreach ($device in $devices) { Write-Host Checking Non Default Values on $device.Name -ForegroundColor Magenta $prop= Get-NetAdapterAdvancedProperty $device.Name foreach ( $temp in $prop) { # Write-Host Current prop is ($temp).DisplayName -BackgroundColor Black # Write-Host Possible values are ($temp).ValidDisplayValues -BackgroundColor Blue if ($temp.DisplayName -ne "Locally Administered Address") { if($temp.DisplayValue -ne $temp.DefaultDisplayValue) { Write-Host "Current " -NoNewline Write-Host $temp.DisplayName -NoNewline -ForegroundColor Cyan Write-Host " is set to " -NoNewline Write-Host $temp.DisplayValue -ForegroundColor Red -NoNewline Write-Host "`tDefault is " -NoNewline Write-Host $temp.DefaultDisplayValue -ForegroundColor Green } }#if LAA } #Prop For each Write-Host `n`n }#Device For Each if($RunOnPeerAsWell) { Write-Host `nChecking non default values on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Get-NonDefaultValues} } }#function ##################################################################Link Testing##################################################### function LinkSettings ($RunOnPeerAsWell) { Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | % { Get-NetAdapterAdvancedProperty -DisplayName 'Link Control', 'Speed*','Flow Control','FEC Mode' -Verbose -InterfaceAlias $_.InterfaceAlias | Select Name, DisplayName, DisplayValue } if($RunOnPeerAsWell) { Write-Host `nGetting LinkSettings from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; LinkSettings} } } function LinkControl { param( [ValidateSet("Preboot controlled", "Driver controlled")]$displayValue, $RunOnPeerAsWell) Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | % { if($displayValue){Set-NetAdapterAdvancedProperty -DisplayName 'Link Control' -DisplayValue $displayValue -Verbose -InterfaceAlias $_.InterfaceAlias} else {Get-NetAdapterAdvancedProperty -DisplayName 'Link Control' -Verbose -InterfaceAlias $_.InterfaceAlias} } if($RunOnPeerAsWell) { Write-Host `nGetting LinkSettings from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; LinkControl -DisplayValue $args[0]} -ArgumentList $displayValue } } function FlowControl { param( [ValidateSet("Auto Negotiation", "Rx & Tx Enabled", "Rx Enabled", "Tx Enabled", "Disabled")]$displayValue, $RunOnPeerAsWell) Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | % { if($displayValue){Set-NetAdapterAdvancedProperty -DisplayName 'Flow Control' -DisplayValue $displayValue -Verbose -InterfaceAlias $_.InterfaceAlias} else{Get-NetAdapterAdvancedProperty -DisplayName 'Flow Control' -Verbose -InterfaceAlias $_.InterfaceAlias} } if($RunOnPeerAsWell) { Write-Host `nGetting LinkSettings from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; FlowControl -DisplayValue $args[0]} -ArgumentList $displayValue } } function SpeedAndDuplex { param( [ValidateSet("Auto Negotiation", "10 Gbps Full Duplex","10 Gbps", "25 Gbps Full Duplex", "25 Gbps", "50 Gbps Auto", "50 Gbps NRZ", "50 Gbps PAM4", "Device Default", "1.0 Gbps Full Duplex","50 Gbps Full Duplex")]$displayValue, $RunOnPeerAsWell) Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | % { if($displayValue){Set-NetAdapterAdvancedProperty -DisplayName 'Speed*' -DisplayValue $displayValue -Verbose -InterfaceAlias $_.InterfaceAlias} else {Get-NetAdapterAdvancedProperty -DisplayName 'Speed*' -Verbose -InterfaceAlias $_.InterfaceAlias} } if($RunOnPeerAsWell) { Write-Host `nGetting LinkSettings from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; SpeedAndDuplex -DisplayValue $args[0]} -ArgumentList $displayValue } } ##################################################################Link Testing End##################################################### ###########################################################Advanced Property END########################################################### ###########################################################IP Address########################################################### function noipv6 { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled' | Where-Object InterfaceDescription -NotMatch "SR-IOV") | Where-Object -Property LinkSpeed -ne '1 Gbps') | foreach { $temp = $_.InterfaceAlias ; Disable-NetAdapterBinding -InterfaceAlias "$temp" -DisplayName *ipv6* -Verbose } } function noipv4 { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled' | Where-Object InterfaceDescription -NotMatch "SR-IOV") | Where-Object -Property LinkSpeed -ne '1 Gbps') | foreach { $temp = $_.InterfaceAlias ; Disable-NetAdapterBinding -InterfaceAlias "$temp" -DisplayName *ipv4* -Verbose } } function ipv6 { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled' | Where-Object InterfaceDescription -NotMatch "SR-IOV") | Where-Object -Property LinkSpeed -ne '1 Gbps') | foreach { $temp = $_.InterfaceAlias ; Enable-NetAdapterBinding -InterfaceAlias "$temp" -DisplayName *ipv6* -Verbose } } function ipv4 { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled' | Where-Object InterfaceDescription -NotMatch "SR-IOV") | Where-Object -Property LinkSpeed -ne '1 Gbps') | foreach { $temp = $_.InterfaceAlias ; Enable-NetAdapterBinding -InterfaceAlias "$temp" -DisplayName *ipv4* -Verbose } } function setip_subnet ($subnet, $lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; #in case of vswitch it will avoid assigning ip on pf if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; $subnet++; } } function setip_lastoctet ($subnet, $lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; if ((Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IPAddress -match "10.30*") { Write-host Skipping assining to CORP interface; return; }; Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; $lastoctet++ } } function setip_dhcp { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; #in case of vswitch it will avoid assigning ip on PF if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; #Set DHCP to IPv4, somehow this doesnt work for IPv6 addresses Set-NetIPInterface -Interfacealias $temp -DHCP Enabled #Disable router Ipv6 addresses Set-NetIPInterface -InterfaceAlias $temp -AddressFamily IPv6 -RouterDiscovery Disabled #Remove Ipv6 addresses from interfaces Remove-NetIPAddress -InterfaceAlias $temp -IPAddress * -AddressFamily IPv6 -Confirm:0 #delete link local ip address if the above doesnt work #Get-NetIPAddress -InterfaceAlias P1 | Where-Object -Property IPAddress -Match "fe80::*" -Verbose | Remove-NetIPAddress -Verbose -Confirm:0 #netsh interface ipv6 delete address "p1" fe80::2c2d:d74b:fc9d:a83f #Remove IPV4 gateway addresses Remove-NetRoute -InterfaceAlias $temp -Confirm:0 } } function setip_lastoctet_full ($ip, $addGateway) { #spilt ip Address [int]$firstOctet, [int]$secondOctet, [int]$subnet, [int]$lastoctet = ($ip).split('.') #Remove IPV6 addresses and assign new IPs using netsh #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; #removing existing Ips Write-Host Removing exisintg IPs on $temp Get-NetIPAddress -InterfaceAlias $temp | Remove-NetRoute -Confirm:0 -ErrorAction SilentlyContinue Get-NetIPAddress -InterfaceAlias $temp | Remove-NetIpAddress -Confirm:0 #build IpAddress $ipAddress = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + $lastoctet #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } if($addGateway) { $v4gateway = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + 1; $v6gateway = [String] "be" + $ipv6subnet + "::" + 1 netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0 $v4gateway; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -DefaultGateway $v6gateway -PrefixLength 64 | Out-Null Write-Host Interface $temp - $ipAddress $v4gateway , be$ipv6subnet::$lastoctet $v6gateway `n; } else { netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -PrefixLength 64 | Out-Null Write-Host Interface $temp - $IpAddress, be$ipv6subnet::$lastoctet `n; } $lastoctet++ } } function setip_subnet_full ($ip, $addGateway) { #spilt ip Address [int]$firstOctet, [int]$secondOctet, [int]$subnet, [int]$lastoctet = ($ip).split('.') #Remove IPV6 addresses and assign new IPs using netsh #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; #removing existing Ips Write-Host Removing exisintg IPs on $temp Get-NetIPAddress -InterfaceAlias $temp | Remove-NetRoute -Confirm:0 -ErrorAction SilentlyContinue Get-NetIPAddress -InterfaceAlias $temp | Remove-NetIpAddress -Confirm:0 #build IpAddress $ipAddress = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + $lastoctet #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } if($addGateway) { $v4gateway = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + 1; $v6gateway = [String] "be" + $ipv6subnet + "::" + 1 netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0 $v4gateway; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -DefaultGateway $v6gateway -PrefixLength 64 | Out-Null Write-Host Interface $temp - $ipAddress $v4gateway , be$ipv6subnet::$lastoctet $v6gateway `n; } else { netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -PrefixLength 64 | Out-Null Write-Host Interface $temp - $IpAddress, be$ipv6subnet::$lastoctet `n; } $subnet++ } } function addGateway ($gatewayIP) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *hyper* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; } #For each } function Join-WinEitDomain { $hostname = hostname.exe Set-DnsClientServerAddress -InterfaceIndex (corpip).InterfaceIndex -ServerAddresses 10.30.35.73 -Validate -Verbose Get-DnsClientServerAddress -InterfaceIndex (corpip).InterfaceIndex -AddressFamily ipv4 Write-Host Adding $hostname to domain Wineit.com Add-Computer -DomainName wineit.com -Credential $cred } function Join-WindowsDomain($ipaddress) { $hostname = hostname.exe Set-NetIPAddress -IPAddress $ipaddress Set-DnsClientServerAddress -InterfaceIndex (corpip).InterfaceIndex -ServerAddresses 10.30.35.65 -Validate -Verbose Get-DnsClientServerAddress -InterfaceIndex (corpip).InterfaceIndex -AddressFamily ipv4 Write-Host Adding $hostname to domain Windows.eit Add-Computer -DomainName windows.eit -Credential $cred } function setip_subnet_vm ($subnet, $lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *hyper-V* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; ; $subnet++ } } function setip_lastoctet_vm ([int]$subnet, [int]$lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *hyper-V* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | foreach { $temp = $_.InterfaceAlias ; Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; $lastoctet++ } } function setip_lastoctet_full_vm ($ip, $addGateway) { #spilt ip Address [int]$firstOctet, [int]$secondOctet, [int]$subnet, [int]$lastoctet = ($ip).split('.') #Remove IPV6 addresses and assign new IPs using netsh #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *hyper-V* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; #removing existing Ips Write-Host Removing exisintg IPs on $temp Get-NetIPAddress -InterfaceAlias $temp | Remove-NetRoute -Confirm:0 -ErrorAction SilentlyContinue Get-NetIPAddress -InterfaceAlias $temp | Remove-NetIpAddress -Confirm:0 #build IpAddress $ipAddress = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + $lastoctet #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } if($addGateway) { $v4gateway = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + 1; $v6gateway = [String] "be" + $ipv6subnet + "::" + 1 netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0 $v4gateway; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -DefaultGateway $v6gateway -PrefixLength 64 | Out-Null Write-Host Interface $temp - $ipAddress $v4gateway , be$ipv6subnet::$lastoctet $v6gateway `n; } else { netsh int ipv4 set address name="$temp" static $ipAddress 255.255.255.0; #netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; New-NetIPAddress -IPAddress be$ipv6subnet::$lastoctet -InterfaceAlias $temp -PrefixLength 64 | Out-Null Write-Host Interface $temp - $IpAddress, be$ipv6subnet::$lastoctet `n; } $lastoctet++ } } function setip_lastoctet_vm_Dartmouth ($subnet, $lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *hyper-V* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' )) | foreach { $temp = $_.InterfaceAlias ; Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; $lastoctet++ } } function setip_team ($subnet, $lastoctet) { #Remove IPV6 addresses and assign new IPs using netsh ((Get-NetAdapter -InterfaceDescription *Marvell*, *multiplex* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; #in case of vswitch it will avoid assigning ip on pf if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; return; }; #Remove-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 -Confirm:0; netsh int ipv4 set address name="$temp" static 192.168.$subnet.$lastoctet 255.255.255.0; #Correcting last octet for IPv6 address if ($subnet -ge 100) { $ipv6subnet = $subnet - 100 } else { $ipv6subnet = $subnet } netsh int ipv6 set address interface="$temp" be$ipv6subnet::$lastoctet; Write-Host Interface $temp - 192.168.$subnet.$lastoctet, be$ipv6subnet::$lastoctet; $subnet++; } } ###########################################################IP Address End########################################################### ###############################################TRAFFIC############################################################ function ntttcp ($mode) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { #Its Dummy now #-InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } #Traffic function ntttcp_bat () { #Put this logic in all setip_* functions #This function handles assiging/trying to assign IPs to interfaces which doesnt have IPV* bindings enabled. i.e to handle hyper vswitch created case param( [Parameter(Mandatory = $true)]$threads, [Parameter(Mandatory = $true)]$time, [Parameter(Mandatory = $true)][int]$port ) $ntttcp_path = "C:\Softwares\NTttcp-v5.33" if (!(test-path $ntttcp_path )) { get NTttcp-v5.33 } #if (test-path $ntttcp_path\ntttcp_receive*.bat) { Remove-Item $ntttcp_path\ntttcp_receive*.bat -Verbose } #if (test-path $ntttcp_path\ntttcp_send*.bat) { Remove-Item $ntttcp_path\ntttcp_send*.bat -Verbose } $interfaces = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper-V*, Mellanox*, *BCM57810* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') foreach ($i in $interfaces) { $temp = $i.Name; if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; } else { $address = [string](Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IPAddress Write-Host Interface $temp - $address "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -r -m $threads,*,$address -t $time -p $port -d`"" | Add-Content $ntttcp_path\ntttcp_receive.bat -Force; "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -s -m $threads,*,$address -t $time -p $port -d`"" | Add-Content $ntttcp_path\ntttcp_send.bat -Force; $port = $port + $threads; Write-Host $port } if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; } else { $address = [string](Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object PrefixOrigin -eq 'Manual').IPAddress Write-Host Interface $temp - $address "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -r -m $threads,*,$address -t $time -p $port -d -6`"" | Add-Content $ntttcp_path\ntttcp_receive_v6.bat -Force; "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -s -m $threads,*,$address -t $time -p $port -d -6`"" | Add-Content $ntttcp_path\ntttcp_send_v6.bat -Force; $port = $port + $threads; Write-Host $port } if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; } else { $address = [string](Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IPAddress Write-Host Interface $temp - $address "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -r -m $threads,*,$address -t $time -p $port -d -u`"" | Add-Content $ntttcp_path\ntttcp_receive_udp.bat -Force; "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -s -m $threads,*,$address -t $time -p $port -d -u`"" | Add-Content $ntttcp_path\ntttcp_send_udp.bat -Force; $port = $port + $threads; Write-Host $port } if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -eq $FALSE) { Write-host in if; } else { $address = [string](Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object PrefixOrigin -eq 'Manual').IPAddress Write-Host Interface $temp - $address "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -r -m $threads,*,$address -t $time -p $port -d -6 -u`"" | Add-Content $ntttcp_path\ntttcp_receive_v6_udp.bat -Force; "start /DC:\Softwares\NTttcp-v5.33 cmd /k `"ntttcp.exe -s -m $threads,*,$address -t $time -p $port -d -6 -u`"" | Add-Content $ntttcp_path\ntttcp_send_v6_udp.bat -Force; $port = $port + $threads; Write-Host $port } } #Checking Peer Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock{ $ntttcp_path = "C:\Softwares\NTttcp-v5.33" if (!(test-path $ntttcp_path )) { get NTttcp-v5.33 } #if (test-path $ntttcp_path\ntttcp_receive*.bat) { Remove-Item $ntttcp_path\ntttcp_receive*.bat -Verbose } #if (test-path $ntttcp_path\ntttcp_send*.bat) { Remove-Item $ntttcp_path\ntttcp_send*.bat -Verbose } } Write-Host Moving sender files to Peer -ForegroundColor Cyan Move-Item $ntttcp_path\ntttcp_send*bat \\$(Get-PeerIp)\c$\Softwares\NTttcp-v5.33\ -Verbose -Force -Confirm:0 ii $ntttcp_path } function L2Traffic { param( $ipv4 = 1, $ipv6 = 0, $threads = 8, $blockSize= "64KB", [ValidateSet("Read-Only","Write-Only","Read-Write")] $testMode="Read-Write" ) if($testMode -eq "Read-Write"){$testMode2 = ""} if($testMode -eq "Read-Only"){$testMode2 = "-r"} if($testMode -eq "Write-Only"){$testMode2 = "-w"} $v4Arr=@() $v6Arr=@() Write-Host Local IPs: -ForegroundColor Yellow ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if((Get-NetAdapterBinding -Name "$temp" -DisplayName "Microsoft NetVsc Failover VF Protocol" -ErrorAction SilentlyContinue).Enabled -ne $true){ if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {Write-Host Disabling router IPv6 addresses on $temp; Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled; $v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object SuffixOrigin -ne LINK).IpAddress;} }#VF Check else { Write-Host "$temp is a VF. Skipping VF interface" -ForegroundColor Yellow } } $v4Arr $v6Arr $remote_v4Arr = @() $remote_v6Arr = @() Write-Host Getting remote IPs from Peer: -ForegroundColor Yellow $remote_v4Arr, $remote_v6Arr = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock { $v4Arr=@() $v6Arr=@() ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if((Get-NetAdapterBinding -Name "$temp" -DisplayName "Microsoft NetVsc Failover VF Protocol" -ErrorAction SilentlyContinue).Enabled -ne $true){ if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {Write-Host Disabling router IPv6 addresses on $temp; Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled; $v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6| Where-Object SuffixOrigin -ne LINK).IpAddress;} }#VF Interface check else { Write-Host "$temp is a VF. Skipping VF interface" -ForegroundColor Yellow } } return $v4Arr, $v6Arr } $remote_v4Arr $remote_v6Arr if($ipv4) { #IPv4 foreach($localip in $v4Arr) { foreach($remoteip in $remote_v4Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): bytes") { #Write-Host $localip-$remoteip #blink pattern no 1 - Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip) $testMode2" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip $testMode2; while(!(Test-Connection $remoteip -Quiet)){Write-Host Waiting for the $remoteip to ping}; sleep 60}" } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } }#IPv4 if if($ipv6) { #IPv6 foreach($localip in $v6Arr) { foreach($remoteip in $remote_v6Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): time") { #Write-Host $localip-$remoteip Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip) $testMode2" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip $testMode2; while(!(Test-Connection $remoteip -Quiet)){Write-Host Waiting for the $remoteip to ping}; sleep 60}" } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } }#IPv6 if } function L2Traffic-toPeerVfs { param( $ipString="192.168", $ipv4 = 1, $ipv6 = 0, $threads = 4, $blockSize= "32KB", $peerIP=$(Get-PeerIp) ) $v4Arr=@() $v6Arr=@() Write-Host Local IPs: -ForegroundColor Yellow ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps') | ForEach { $temp = $_.InterfaceAlias ; if((Get-NetAdapterBinding -Name "$temp" -DisplayName "Microsoft NetVsc Failover VF Protocol" -ErrorAction SilentlyContinue).Enabled -ne $true){ if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {Write-Host Disabling router IPv6 addresses on $temp; Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled; $v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object SuffixOrigin -ne LINK).IpAddress;} }#VF Check else { Write-Host "$temp is a VF. Skipping VF interface" -ForegroundColor Yellow } } $v4Arr $v6Arr $remote_v4Arr = @() Write-Host Getting remote IPs from Peer: -ForegroundColor Yellow #VF rdma from peer to VF Write-Host Getting VF IPs matching $ipString from $peerIP -ForegroundColor Cyan $remote_v4Arr = Invoke-Command -Authentication Negotiate -ComputerName $peerIP -Credential $cred -ScriptBlock {(Get-VM | Where-Object State -eq "Running" | Get-VMNetworkAdapter | Where-Object SwitchName -ne $null).IpAddresses} | Select-String "$ipString" $remote_v4Arr #IPv4 foreach($remoteip in $remote_v4Arr) { foreach($localip in $v4Arr) { Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip)" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip; while(!(Test-Connection $remoteip -Quiet)){Write-Host Waiting for the $remoteip to ping}}" } } } function L2Traffic1x1_Old { param( $ipv4 = 1, $ipv6 = 1, $threads = 4, $blockSize= "64KB" ) $v4Arr=@() $v6Arr=@() Write-Host Local IPs: -ForegroundColor Yellow ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps'| Where-Object -Property InterfaceDescription -NotMatch "SR-IOV") | ForEach { $temp = $_.InterfaceAlias ; if ((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp") -ne $null) { if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} } if ((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp") -ne $null) { if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled -Verbose -ErrorAction SilentlyContinue; $v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object SuffixOrigin -ne LINK).IpAddress;} } } $v4Arr $v6Arr $remote_v4Arr = @() $remote_v6Arr = @() Write-Host Getting remote IPs from Peer: -ForegroundColor Yellow $remote_v4Arr, $remote_v6Arr = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock { $v4Arr=@() $v6Arr=@() ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps' | Where-Object -Property InterfaceDescription -NotMatch "SR-IOV" ) | ForEach { $temp = $_.InterfaceAlias ; Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled -Verbose if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {$v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6| Where-Object SuffixOrigin -ne LINK).IpAddress;} } return $v4Arr, $v6Arr } $remote_v4Arr $remote_v6Arr #IPv4 if($ipv4) { foreach($localip in $v4Arr) { foreach($remoteip in $remote_v4Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): bytes") { #Write-Host $localip-$remoteip Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip)" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip}" #$remote_v4List.Remove($remoteip) break } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } } if($ipv6) { #IPv6 foreach($localip in $v6Arr) { foreach($remoteip in $remote_v6Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): time") { #Write-Host $localip-$remoteip Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip)" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip}" #$remote_v6List.Remove($remoteip) break } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } } } function L2Traffic1x1 { param( $ipv4 = 1, $ipv6 = 1, $threads = 4, $blockSize= "64KB" ) $v4Arr=[System.Collections.ArrayList]::new(); $v6Arr=[System.Collections.ArrayList]::new(); Write-Host Local IPs: -ForegroundColor Yellow ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps'| Where-Object -Property InterfaceDescription -NotMatch "SR-IOV") | ForEach { $temp = $_.InterfaceAlias ; if ((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp") -ne $null) { if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} } if ((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp") -ne $null) { if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled -Verbose -ErrorAction SilentlyContinue; $v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6 | Where-Object SuffixOrigin -ne LINK).IpAddress;} } } $v4Arr $v6Arr $remote_v4Arr = [System.Collections.ArrayList]::new() $remote_v6Arr = [System.Collections.ArrayList]::new() Write-Host Getting remote IPs from Peer: -ForegroundColor Yellow $remote_v4Arr, $remote_v6Arr = Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -ScriptBlock { $v4Arr=[System.Collections.ArrayList]::new() $v6Arr=[System.Collections.ArrayList]::new() ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps' | Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps' | Where-Object -Property InterfaceDescription -NotMatch "SR-IOV" ) | ForEach { $temp = $_.InterfaceAlias ; Set-NetIPInterface -InterfaceAlias $_.InterfaceAlias -AddressFamily IPv6 -RouterDiscovery Disabled -Verbose if (((Get-NetAdapterBinding -DisplayName *ipv4* -Name "$temp").Enabled) -ne $FALSE) {$v4Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv4).IpAddress;} if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name "$temp").Enabled) -ne $FALSE) {$v6Arr += (Get-NetIPAddress -InterfaceAlias "$temp" -AddressFamily IPv6| Where-Object SuffixOrigin -ne LINK).IpAddress;} } return $v4Arr, $v6Arr } $remote_v4Arr $remote_v6Arr #IPv4 if($ipv4) { foreach($localip in $v4Arr) { foreach($remoteip in $remote_v4Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): bytes") { #Write-Host $localip-$remoteip Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip)" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip}" $remote_v4Arr.Remove($remoteip) break } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } } if($ipv6) { #IPv6 foreach($localip in $v6Arr) { foreach($remoteip in $remote_v6Arr) { Write-Host "pinging $remoteip from $localip :" -NoNewline -ForegroundColor Cyan $ping = (ping $remoteip -S $localip -n 2)[3] #$ping if($ping -match "Reply from $($remoteip): time") { #Write-Host $localip-$remoteip Write-Host "Success. Starting sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f$($localip)-$($remoteip)" -ForegroundColor Green Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock $blockSize -b$blockSize -t$threads -o -l40 -Y1 -M50 -f`'$localip-$remoteip`' --handler=all:xip}" $remote_v6Arr.Remove($remoteip) break } else { Write-Host "ping failed : $ping" -ForegroundColor DarkYellow } } } } } function L2Stats { param( [Parameter(Mandatory = $false)] [ValidateSet('MBps', 'Gbps')] $Unit = "Gbps", [Parameter(Mandatory = $false)] $maxSamples = 10, [Parameter(Mandatory = $false)] $IncludeHypervInterfaces ) #For all adapters $j = 0 $counter=1 while ($counter -le $maxSamples) { if ($IncludeHypervInterfaces) { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } else { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } #Write-Host $adapterList $i = 0 $count = $adapterList.Count #Write-Host $count if ($j % 10 -eq 0) { while ($i -lt $count) { Write-Host $adapterList[$i] `t`t`t`t -NoNewLine -ForegroundColor Yellow $i++ } Write-Host `n $i = 0 while ($i -lt $count) { Write-Host Inbound`t`t OutBound`t -NoNewLine -ForegroundColor DarkCyan $i++ } } $j++ Write-Host `n $i = 0 while ($i -lt $count) { if ($Unit -eq 'MBps') { $a = Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i] #Write-Host $adapterList[$i] Start-Sleep 1 $b = Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i] $inbound = [math]::Round((($b.ReceivedBytes - $a.ReceivedBytes) / 1MB), 2) $outbound = [math]::Round((($b.SentBytes - $a.SentBytes) / 1MB), 2) #Write-Host $adapterList[$i] `t -NoNewLine Write-Host $inbound MBps - $outbound MBps `t -NoNewLine $i++ } elseif ($Unit -eq 'Gbps') { $a = Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i] #Write-Host $adapterList[$i] Start-Sleep 1 $b = Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i] $inbound = [math]::Round((($b.ReceivedBytes - $a.ReceivedBytes)/1MB)/125, 2) $outbound = [math]::Round((($b.SentBytes - $a.SentBytes)/1MB)/125, 2) #Below doesnt match withtaskmgr, gives 1 to 1.5 G more than task mgr #$inbound = [math]::Round(((($b.ReceivedBytes - $a.ReceivedBytes)/1MB)*8*1024*1024)/1000000000, 2) #$outbound = [math]::Round(((($b.SentBytes - $a.SentBytes)/1MB)*8*1024*1024)/1000000000, 2) #Write-Host $adapterList[$i] `t -NoNewLine Write-Host $inbound Gbps - $outbound Gbps `t -NoNewLine $i++ } } Write-Host `n $counter++ } } ###############################################ROCE / RDMA/ iWARP#################################################### function rocev1 ($RunOnPeerAsWell){ ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "RDMA mode" -DisplayValue "Roce V1" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue ; Set-NetAdapterAdvancedProperty -DisplayName "NetworkDirect Technology" -DisplayValue "RoCE" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue } if($RunOnPeerAsWell) { Write-Host `nSetting RoCE Mode to RoCEv1 on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; rocev1} } } function rocev2 ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "RDMA mode" -DisplayValue "Roce V2" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue; Set-NetAdapterAdvancedProperty -DisplayName "NetworkDirect Technology" -DisplayValue "RoCEV2" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue } if($RunOnPeerAsWell) { Write-Host `nSetting RDMA mode ROCEv2 on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; rocev2} } } function iwarp ($RunOnPeerAsWell) { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Set-NetAdapterAdvancedProperty -DisplayName "RDMA mode" -DisplayValue "iwarp" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue; Set-NetAdapterAdvancedProperty -DisplayName "NetworkDirect Technology" -DisplayValue "iWarp" -Verbose -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue } if($RunOnPeerAsWell) { Write-Host `nSetting RDMA mode iWarp on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; iwarp} } } function dis-RDMA { Disable-NetAdapterRDMA * -Verbose } function en-RDMA { Enable-NetAdapterRDMA * -Verbose } function RDMA { Get-NetAdapterRDMA } function smbConnectionState { RDMAConnectionState} function RDMAConnectionState {smbConnection | fl *rdma*, *channel*, *ip*} function ROCEMTU($MTUSize, $RunOnPeerAsWell) { NDMTU $MTUSize $RunOnPeerAsWell } function RDMAMTU($MTUSize, $RunOnPeerAsWell) { NDMTU $MTUSize $RunOnPeerAsWell } function NDMTU { param( [Parameter(Mandatory = $false)] [ValidateSet(256, 512, 1024, 2048, 4096)] [int]$MTUSize, $RunOnPeerAsWell ) ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { if ($MTUSize) { Set-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "RoCE MTU Size" -DisplayValue $MTUSize -Verbose } else { Get-NetAdapterAdvancedProperty -InterfaceAlias $_.InterfaceAlias -DisplayName "RoCE MTU Size" } } if($RunOnPeerAsWell) { Write-Host `nSetting/Getting NDMTU on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; NDMTU -MTUSize $args[0]} -ArgumentList $MTUSize } } function RDMAMaxQPsNumbers($value, $RunOnPeerAsWell) { if ($value) { Get-NetAdapterAdvancedProperty -DisplayName "RDMA Max QPs Number" | % { Set-NetAdapterAdvancedProperty -DisplayName $_.DisplayName -DisplayValue $value -Verbose -InterfaceDescription $_.INterfaceDescription } } else { Get-NetAdapterAdvancedProperty -DisplayName "RDMA Max QPs Number" } if($RunOnPeerAsWell) { Write-Host `nSetting/Getting RDMA Max QP number on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; RDMAMaxQPsNumbers -value $args[0]} -ArgumentList $value } } function routeCommands ($RunOnPeerAsWell) { route add 20.20.20.0 mask 255.255.255.0 21.21.21.1 -p route add 21.21.21.0 mask 255.255.255.0 20.20.20.1 -p route add be20::0/64 be21::1 -p route add be21::0/64 be20::1 -p if($RunOnPeerAsWell) { Write-Host `nSetting route commands on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; routeCommands} } } function routeCommands99 ($RunOnPeerAsWell) { route add 98.98.98.0 mask 255.255.255.0 99.99.99.1 -p route add 99.99.99.0 mask 255.255.255.0 98.98.98.1 -p route add be98::0/64 be99::1 -p route add be99::0/64 be98::1 -p if($RunOnPeerAsWell) { Write-Host `nSetting route commands on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; routeCommands} } } function routeCommands95 ($RunOnPeerAsWell) { route add 95.95.95.0 mask 255.255.255.0 95.95.95.1 -p route add 96.96.96.0 mask 255.255.255.0 96.96.96.1 -p route add be95::0/64 be95::1 -p route add be96::0/64 be96::1 -p if($RunOnPeerAsWell) { Write-Host `nSetting route commands on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; routeCommands} } } function Create-RamDisks ($RunOnPeerAsWell) { if (!(Test-Path C:\Softwares\roce_scripts)) { get roce_scripts } C:\Softwares\roce_scripts\rdma.bat if($RunOnPeerAsWell) { Write-Host `nCreating Ramdisks on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Create-RamDisks} } } function Ramdisks ($RunOnPeerAsWell) { Create-RamDisks -RunOnPeerAsWell $RunOnPeerAsWell } function Create-RamDisksInVm { if (!(Test-Path C:\Softwares\roce_scripts)) { get roce_scripts } C:\Softwares\roce_scripts\rdma_vm.bat } function RamdisksInVM ($RunOnPeerAsWell) { Create-RamDisksInVm -RunOnPeerAsWell $RunOnPeerAsWell } function RamDisks2() { param( $NoOfDisks = 8, $SizeInGorM = "1G" ) Write-Host Removing exising RamDisks -ForegroundColor Yellow noImdisk Write-Host Getting Free Driver letters from the system -ForegroundColor Yellow $arr=@() 0..25 | %{ $arr += [char]($_ + [byte][char] 'A');} $ExistingLetters = (Get-PSDrive | Where-Object Provider -match "FileSystem").Name $FreeLetters=@() foreach ($item in $arr) { if($ExistingLetters -notcontains $item) { $FreeLetters += "$item" + ":" } } $diskCount = $NoOfDisks if($diskCount -gt $FreeLetters.Count) { Write-Host Creating $FreeLetters.Count disks as only $FreeLetters.Count driver letters are available. $diskCount = $FreeLetters.Count } Write-Host Creating disks -ForegroundColor Yellow for($i=0; $i -lt $diskCount; $i++) { Write-Host "imdisk -a -s $SizeInGorM -m $($FreeLetters[$i]) -p `"/fs:ntfs /q /y`" New-SMBShare -Name `"Ram_Disk$($i+1)`" -Path $($FreeLetters[$i])\ -FullAccess Everyone;" imdisk -a -s $SizeInGorM -m $($FreeLetters[$i]) -p `"/fs:ntfs /q /y`" $path = $FreeLetters[$i]+'\' New-SMBShare -Name "Ram_Disk$($i+1)" -Path $path -FullAccess Everyone -Verbose; } Write-Host Created following smb shares -ForegroundColor Yellow Get-SmbShare -Name Ram_Disk* }#Function function DiskFreeLetters { Write-Host "Getting Free Driver letters from the system :- " -ForegroundColor Yellow -NoNewline $arr=@() #Mapping needs to be started from B: as medusa gui doesnt list A: drive. Medusa maim through command line lists it. 0..24 | %{ $arr += [char]($_ + [byte][char] 'B');} $ExistingLetters = (Get-PSDrive | Where-Object Provider -match "FileSystem").Name $FreeLetters=@() foreach ($item in $arr) { if($ExistingLetters -notcontains $item) { $FreeLetters += "$item" + ":" } } Write-Host Existing Letters : $ExistingLetters Write-Host Free Letters: $FreeLetters } function map { param( $hostip = $(Get-PeerIp) ) [string[]]$PeerIPAddresses; $PeerIPAddresses = Invoke-Command -Authentication Negotiate -ComputerName $hostip -ScriptBlock { (Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, *hyper-V*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property Status -eq 'Up' | Where-Object -Property LinkSpeed -ne '100 Mbps' | Where-Object -Property LinkSpeed -ne '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps' | %{ if((((Get-NetAdapterBinding -DisplayName *ipv4* -Name $_.InterfaceAlias -ErrorAction SilentlyContinue).Enabled) -eq $true)) { Write-Host $_.InterfaceAlias in if; $intIp = (Get-NetIPAddress -InterfaceIndex $_.InterfaceIndex | Where-Object Type -eq Unicast | Where-Object AddressFamily -eq IPv4).IPv4Address if((Test-connection $intIp -Quiet) -eq $true ) { [string]$ip = $intIp return $ip } } } } $PeerSmbShares = Invoke-Command -Authentication Negotiate -ComputerName $hostip -ScriptBlock {(Get-SmbShare | Where-Object Name -Match ram_disk*).Name} $PeerIPAddresses $PeerSmbShares $ipCount = $PeerIPAddresses.Count Write-host IPCOUNT $ipCount $shareCount = $PeerSmbShares.Count #Removing existing mappings Write-Host Removing existing mappings netusedelete Write-Host "Getting Free Driver letters from the system :- " -ForegroundColor Yellow -NoNewline $arr=@() #Mapping needs to be started from B: as medusa gui doesnt list A: drive. Medusa maim through command line lists it. 0..24 | %{ $arr += [char]($_ + [byte][char] 'B');} $ExistingLetters = (Get-PSDrive | Where-Object Provider -match "FileSystem").Name $FreeLetters=@() foreach ($item in $arr) { if($ExistingLetters -notcontains $item) { $FreeLetters += "$item" + ":" } } Write-Host $FreeLetters.Length if($shareCount -gt $FreeLetters.Length) { Write-Host Not enough free disk letters available to map, Reducing ShareCount to $FreeLetters.Length -ForegroundColor Red; $shareCount = $FreeLetters.Length } $i=0 $j=$i while($i -lt $shareCount) { if($j -ge $ipCount){$j=0} Write-Host net use $FreeLetters[$i] \\$($PeerIPAddresses[$j])\$($PeerSmbShares[$i]) net use $FreeLetters[$i] \\$($PeerIPAddresses[$j])\$($PeerSmbShares[$i]) $i++ $j++ } Get-SmbMultichannelConnection } function mapv6 { param( $hostip = $(Get-PeerIp) ) $PeerIPAddresses = Invoke-Command -Authentication Negotiate -ComputerName $hostip -ScriptBlock {(Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, *hyper-V*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -ne '100 Mbps' | Where-Object -Property LinkSpeed -ne '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps' | %{if (((Get-NetAdapterBinding -DisplayName *ipv6* -Name $_.InterfaceAlias).Enabled) -ne $FALSE) {(Get-NetIPAddress -InterfaceIndex $_.InterfaceIndex | Where-Object Type -eq Unicast | Where-Object AddressFamily -eq IPv6 | Where-Object PrefixOrigin -eq Manual).IPv6Address}}} $PeerSmbShares = Invoke-Command -Authentication Negotiate -ComputerName $hostip -ScriptBlock {(Get-SmbShare | Where-Object Name -Match ram_disk*).Name} $PeerHostName = [system.net.dns]::GetHostByAddress($hostip).hostname Write-host Selected IP for mapping - ${PeerIPAddresses[0]} Write-host Updating hostfile "`n$($PeerIPAddresses[0]) `t $PeerHostName" | Out-File C:\Windows\System32\drivers\etc\hosts -Append -Encoding ascii; Ping $PeerHostName $PeerSmbShares $ipCount = $PeerIPAddresses.Count $shareCount = $PeerSmbShares.Count #Removing existing mappings Write-Host Removing existing mappings netusedelete Write-Host "Getting Free Driver letters from the system :- " -ForegroundColor Yellow -NoNewline $arr=@() #Mapping needs to be started from B: as medusa gui doesnt list A: drive. Medusa maim through command line lists it. 0..24 | %{ $arr += [char]($_ + [byte][char] 'B');} $ExistingLetters = (Get-PSDrive | Where-Object Provider -match "FileSystem").Name $FreeLetters=@() foreach ($item in $arr) { if($ExistingLetters -notcontains $item) { $FreeLetters += "$item" + ":" } } Write-Host $FreeLetters.Length if($shareCount -gt $FreeLetters.Length) { Write-Host Not enough free disk letters available to map, Reducing ShareCount to $FreeLetters.Length -ForegroundColor Red; $shareCount = $FreeLetters.Length } $i=0 $j=$i while($i -lt $shareCount) { #if($j -ge $ipCount){$j=0} Write-Host net use $FreeLetters[$i] \\$($PeerHostName)\$($PeerSmbShares[$i]) net use $FreeLetters[$i] \\$($PeerHostName)\$($PeerSmbShares[$i]) $i++ #$j++ } Get-SmbMultichannelConnection } function noImdisk ($RunOnPeerAsWell) { imdisk -l -n | % { imdisk -u $_ -D } Write-Host Removing smb network shares get-smbshare -Name ram* | Remove-SmbShare -Verbose -Confirm:0 if($RunOnPeerAsWell) { Write-Host `nRemoving Ram Disks on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; noImdisk} } } function NewImdisk ([string]$SizeinGB, $shareName) { $SizeinGB = $SizeinGB + "G" imdisk -a -s $SizeinGB -m V: -p `"/fs:ntfs /q /y`" if ($shareName) { New-SmbShare -Name $ShareName -Path V:\ -FullAccess Everyone } } function map.bat { param( $edit=0 ) if (!(Test-Path C:\Softwares\roce_scripts\map.bat)) { get roce_scripts } if($edit) { Start-Process notepad -ArgumentList C:\Softwares\roce_scripts\map.bat -Wait } C:\Softwares\roce_scripts\map.bat } function map4port.bat { param( $edit=0 ) if (!(Test-Path C:\Softwares\roce_scripts\map4port.bat)) { get roce_scripts } if($edit) { Start-Process notepad -ArgumentList C:\Softwares\roce_scripts\map4port.bat -Wait } C:\Softwares\roce_scripts\map4port.bat } function smbTrafficMaim ($ip, $lastoctetRange, $blockSizeInKBorMB, $threads) { #spilt ip Address [int]$firstOctet, [int]$secondOctet, [int]$subnet, [int]$lastoctet = ($ip).split('.') #$fileSize = $blockSizeInKBorMB * 2; $fileSize = "10MB" $start = $lastoctet; Write-host $start; $end = $lastoctetRange #VF rdma from peer to VF $start..$end | % { #$filename = (corpip).ipaddress $lastoctet = $_; $ipAddress = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + $lastoctet $target = "\\$ipAddress\Ram_disk1\$_$(Get-Random).dat" $args = "-Command while(1){maim $fileSize -b$blockSizeInKBorMB -t$threads -Q2 --full-device -o -l35 -L1 -Y1 -M50 -f'$target' -!3 --exit-grace-period=10 --handler=all:xip; while(!(Test-Connection $ipAddress -Quiet)){Write-Host Waiting for the $ipAddress to ping};while(!(Test-path \\$ipAddress\Ram_disk1)){Write-Host Waiting for \\$ipAddress\Ram_disk1 connectivity;Sleep 1;}sleep 10}" $args Start-Process powershell -ArgumentList $args } } function SmbTrafficMaim-toPeerVFs { param( [Parameter(Mandatory = $true)]$ipString, $fileSize = "10MB", $blockSizeInKBorMB="128KB", $threads=2, [ValidateSet("Read-Only","Write-Only","Read-Write")] $testMode="Read-Write", $peerIP=$(Get-PeerIp) ) if($testMode -eq "Read-Write"){$testMode2 = ""} if($testMode -eq "Read-Only"){$testMode2 = "-r"} if($testMode -eq "Write-Only"){$testMode2 = "-w"} #VF rdma from peer to VF Write-Host Getting VF IPs matching $ipString from $peerIP -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {(Get-VM | Where-Object State -eq "Running" | Get-VMNetworkAdapter | Where-Object SwitchName -ne $null).IpAddresses} | Select-String "$ipString" | %{ $fileSize = "10MB" $blockSizeInKBorMB="128KB" $threads=2 $target = "\\$_\Ram_disk1\$_-$(Get-Random).dat, \\$_\Ram_disk2\$_-$(Get-Random).dat,\\$_\Ram_disk3\$_-$(Get-Random).dat,\\$_\Ram_disk4\$_-$(Get-Random).dat,\\$_\Ram_disk5\$_-$(Get-Random).dat,\\$_\Ram_disk6\$_-$(Get-Random).dat,\\$_\Ram_disk7\$_-$(Get-Random).dat,\\$_\Ram_disk8\$_-$(Get-Random).dat" $args = "-Command while(1){maim $fileSize -b$blockSizeInKBorMB -t$threads -Q2 --full-device -o -l35 -L1 -Y1 -M50 -f'$target' -!3 --exit-grace-period=10 --handler=all:xip $testMode2; while(!(Test-Connection $_ -Quiet)){Write-Host Waiting for the $_ to ping};while(!(Test-path \\$_\Ram_disk1)){Write-Host Waiting for \\$_\Ram_disk1 connectivity;Sleep 1;};sleep 10}" $args Start-Process powershell -ArgumentList $args } } function SmbTrafficMaim-toPeerVFsIpv6 { param( [Parameter(Mandatory = $true)]$ipString, $fileSize = "10MB", $blockSizeInKBorMB="128KB", $threads=2, $peerIP=$(Get-PeerIp) ) #VF rdma from peer to VF Write-Host Getting VF IPs matching $ipString from $peerIP -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {(Get-VM | Where-Object State -eq "Running" | Get-VMNetworkAdapter | Where-Object SwitchName -ne $null).IpAddresses} | Select-String "$ipString" | %{ $PeerHostName = [system.net.dns]::GetHostByAddress($_).hostname $fileSize = "10MB" $blockSizeInKBorMB="128KB" $target = "\\$PeerHostName\Ram_disk1\$PeerHostName-$(Get-Random).dat, \\$PeerHostName\Ram_disk2\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk3\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk4\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk5\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk6\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk7\$PeerHostName-$(Get-Random).dat,\\$PeerHostName\Ram_disk8\$PeerHostName-$(Get-Random).dat" $args = "-Command while(1){maim $fileSize -b$blockSizeInKBorMB -t$threads -Q2 --full-device -o -l35 -L1 -Y1 -M50 -f'$target' -!3 --exit-grace-period=10 --handler=all:xip; while(!(Test-Connection $_ -Quiet)){Write-Host Waiting for the $_ to ping};while(!(Test-path \\$PeerHostName\Ram_disk1)){Write-Host Waiting for \\$PeerHostName\Ram_disk1 connectivity;Sleep 1;};sleep 10}" $args Start-Process powershell -ArgumentList $args } } function SmbTrafficDiskSpd-toPeerVFs { param( [Parameter(Mandatory = $true)]$ipString, $fileSize = "10M", $blockSizeInKorM="128K", $threads=2, $peerIP=$(Get-PeerIp) ) #VF rdma from peer to VF Write-Host Getting VF IPs matching $ipString from $peerIP -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {(Get-VM | Where-Object State -eq "Running" | Get-VMNetworkAdapter | Where-Object SwitchName -ne $null).IpAddresses} | Select-String "$ipString" | %{ $fileSize = "10M" $blockSizeInKBorMB="128K" $threads=2 $target = "\\$_\Ram_disk1\$_-$(Get-Random).dat, \\$_\Ram_disk2\$_-$(Get-Random).dat,\\$_\Ram_disk3\$_-$(Get-Random).dat,\\$_\Ram_disk4\$_-$(Get-Random).dat,\\$_\Ram_disk5\$_-$(Get-Random).dat,\\$_\Ram_disk6\$_-$(Get-Random).dat,\\$_\Ram_disk7\$_-$(Get-Random).dat,\\$_\Ram_disk8\$_-$(Get-Random).dat" $args = "-Command while(1){diskspd -c$fileSize -w50 -b$blockSizeInKorM -W5 -d99999999999999 -P -Sh $target; sleep 30;}" $args Start-Process powershell -ArgumentList $args } } function smbTrafficDiskspd ($ip, $lastoctetRange, $blockSizeInKorM) { #spilt ip Address [int]$firstOctet, [int]$secondOctet, [int]$subnet, [int]$lastoctet = ($ip).split('.') #$fileSize = $blockSizeInKBorMB * 2; $fileSize = "1MB" $start = $lastoctet; $end = $lastoctetRange #VF rdma from peer to VF $start..$end | % { #$filename = (corpip).ipaddress $lastoctet = $_; $ipAddress = [String] $firstOctet + "." + $secondOctet + "." + $subnet + "." + $lastoctet $target = "\\$ipAddress\Ram_disk1\$_.dat" $args = "-Command while(1){diskspd -c1M -w50 -b$blockSizeInKorM -W5 -d99999999999999 -P -Sh $target; sleep 5;}" $args Start-Process powershell -ArgumentList $args } } #traffic function RDMA+L2 ($blockSizeInKBorMB, $threads) { #map.bat #Setting medusa #route change 0.0.0.0 mask 0.0.0.0 10.30.32.1 metric 1; #Restart-Service -Name maa* -Verbose -Force (Get-SmbMultichannelConnection | Where-Object ClientIpAddress -NotMatch "10.30") | % { $sutAddress = $_.ClientIpAddress; $peerAddress = $_.ServerIpAddress; Start-Process cmd -ArgumentList "/k powershell.exe -Command while(1){sock -f`'$sutAddress-$peerAddress`' -t$threads -b$blockSizeInKBorMB -Y1 -M30 -o -l40 --handler=all:xip; sleep 30}" } } function Start-RDMA-Maim { RDMATraffic-Maim } function Start-RDMA-DiskSpd { RDMATraffic-diskspd } function RDMAMaim { param( [ValidateSet("MaimFullDeviceCoverage","MaimBandwidthFullDuplex")] $TrafficScript="MaimFullDeviceCoverage", [ValidateSet("Read-Only","Write-Only","Read-Write")] $testMode="Read-Write"#notimplemented ) RDMATraffic-Maim -TrafficScript $TrafficScript -testMode $testMode } function RDMADiskSpd { RDMATraffic-diskspd } function RDMATraffic-Maim { param( [ValidateSet("Read-Only","Write-Only","Read-Write")] $testMode="Read-Write",#notimplemented [ValidateSet("MaimFullDeviceCoverage","MaimBandwidthFullDuplex")] $TrafficScript="MaimFullDeviceCoverage" ) if($testMode -eq "Read-Only") {$testMode2 = "-r"} elseif($testMode -eq "Write-Only") {$testMode2 = "-w"} else{$testMode2 = ""} #Write-host ============================== testmode $testMode == testmode2 $testMode2 #get network mapped disks $DriveList = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | Where-Object -Property FileSystem -eq "NTFS" if ($DriveList -eq $null) { Write-Host No network drivers are mapped. -ForegroundColor Red; return; } #($DriveList).DeviceID | %{ Remove-Item $_\targetfile.dat -Confirm:0 -Force -Verbose} #to get unique file name for each host $filename = (corpip).IpAddress + "_" + (Get-Random) + ".dat" $Drivestring = "" ($DriveList).DeviceID | % { $string = $string + "$_\$filename," } #get free disk space (minimum of all) and create file with 80% of the free space left on the disk #[int]$fileSize = (((($DriveList).FreeSpace | Measure-Object -Minimum).Minimum)/1MB)*0.8 #Setting medusa #route change 0.0.0.0 mask 0.0.0.0 10.30.32.1 metric 1; if($TrafficScript -eq "MaimFullDeviceCoverage") { Write-Host "Starting SMB (Maim Full Device Coverage script) traffic on targets - $string" -ForegroundColor DarkGreen $arg = "-Command while(1){maim 10MB -b128KB -Q16 --full-device -o -l35 -L1 -Y1 -M50 -f'$string' --handler=all:xip $testMode2; sleep 30}" } if($TrafficScript -eq "MaimBandwidthFullDuplex") { Write-Host "Starting SMB (Maim Bandwidth Full Duplex script) traffic on targets - $string" -ForegroundColor DarkGreen $arg = "-Command while(1){maim 4MB -b512KB -Q8 -m16 -n -u -o -l69 -Y1 -M50 --perf-mode -f'$string' --handler=all:xip $testMode2; sleep 30}" } # Maim Bandwidth - Full Duplex - maim 4MB -b512KB -Q8 -m16 -n -u -o -l69 -d30 -Y1 -M5 --perf-mode Start-Process powershell -ArgumentList $arg Start-Process powershell -ArgumentList "RDMAstats Gbps" sleep 5 RDMAConnections } function RDMATraffic-diskspd { param ( $blockSizeInKorM="256K", [ValidateSet("Read-Only","Write-Only","Read-Write")] $testMode="Read-Write" ) if($testMode -eq "Read-Write"){$testMode2 = "50"} if($testMode -eq "Read-Only"){$testMode2 = "0"} if($testMode -eq "Write-Only"){$testMode2 = "100"} if (!(Test-Path C:\windows\System32\diskspd.exe)) { get-diskspd } #get network mapped disks $DriveList = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=4" | Where-Object -Property FileSystem -eq "NTFS" $Drivestring = "" $filename = (corpip).IpAddress + "_" + (Get-Random) + ".dat" ($DriveList).DeviceID | % { $string = $string + " $_\$filename" } #get free disk space (minimum of all) and create file with 80% of the free space left on the disk #$fileSize = [int]((((($DriveList).FreeSpace | Measure-Object -Minimum).Minimum) / 1MB) * 0.8) $filesize = 10 $fileSize = [string] $fileSize + 'M' $arg = "-Command Write-Host diskspd -c$fileSize -w$testMode2 -b$blockSizeInKorM -W5 -d99999999999999 -P -Sh $string; while(1){diskspd -c$fileSize -w$testMode2 -b$blockSizeInKorM -W5 -d99999999999999 -P -Sh $string}" Start-Process powershell -ArgumentList $arg Start-Process powershell -ArgumentList "RDMAstats Gbps" RDMAConnections } function perfmon.html ($RunOnPeerAsWell) { if (!(Test-Path C:\Softwares\perfmon.html)) { get perfmon.html } #C:\Softwares\perfmon.html & 'C:\Program Files\Internet Explorer\iexplore.exe' file:///C:/Softwares/perfmon.html if($RunOnPeerAsWell) { Write-Host `nOpening Perfmon.html on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; perfmon.html} } } function lodctr_MarvellStats { if ((Get-PnpDevice | where -Property Service -eq 'l2nd2') -ne $null) { Get-Item C:\Windows\System32\drivers\qenda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'checked_x86-64' } else { $driverType = 'retail_x86-64' } $driverVersion = $_.VersionInfo.FileVersion Write-Host Currently installed NDIS version is $_.Name - $_.VersionInfo.FileVersion $driverType } } #Lodctr supports network location but doesnt add the stats #Any man file (could be from same branch) works, we not necessarily want the same man file if (!(Test-Path c:\EIT_Drivers\qend\$driverVersion\qlgc\$driverType\qend.man)) { get-NDIS $driverVersion } $string = "c:\EIT_Drivers\qend\$driverVersion\qlgc\$driverType\qend.man" lodctr /M:$string perfmon.html } function unlodctr_MarvellStats { unlodctr.exe /g:"{e2a4ae01-38db-4da2-84fe-00afeae9893e}" } function RDMAActiveConnections($RunOnPeerAsWell, $WaitTillZero) { Write-Host Active Connections $conn = ((Get-NetAdapterStatistics).RdmaStatistics).ActiveConnections $conn if($WaitTillZero) { while($conn -ne 0) { sleep 1 RDMAActiveConnections } } if($RunOnPeerAsWell) { Write-Host `nGetting Active connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; RDMAActiveConnections} } } function RDMAFailedConnections($RunOnPeerAsWell) { Write-Host Failed Connections ((Get-NetAdapterStatistics).RdmaStatistics).FailedConnectionAttempts if($RunOnPeerAsWell) { Write-Host `nGetting failed connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; RDMAFailedConnections} } } function RDMAAcceptedConnections($RunOnPeerAsWell) { Write-Host Accepted Connections ((Get-NetAdapterStatistics).RdmaStatistics).AcceptedConnections if($RunOnPeerAsWell) { Write-Host `nGetting Accepted connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; RDMAAcceptedConnections} } } function RDMAInitiatedConnections($RunOnPeerAsWell) { Write-Host Initiated Connections ((Get-NetAdapterStatistics).RdmaStatistics).InitiatedConnections if($RunOnPeerAsWell) { Write-Host `nGetting Initiated connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; RDMAInitiatedConnections} } } function ActiveConnections ($RunOnPeerAsWell, $WaitTillZero) { RDMAActiveConnections $RunOnPeerAsWell $WaitTillZero} function FailedConnections ($RunOnPeerAsWell) { RDMAFailedConnections $RunOnPeerAsWell } function AcceptedConnections ($RunOnPeerAsWell) { RDMAAcceptedConnections $RunOnPeerAsWell } function InitiatedConnections ($RunOnPeerAsWell) { RDMAInitiatedConnections $RunOnPeerAsWell} function RDMAConnections ($RunOnPeerAsWell) { Get-Date AcceptedConnections ActiveConnections FailedConnections InitiatedConnections if($RunOnPeerAsWell) { Write-Host `nGetting RDMA connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; AcceptedConnections ActiveConnections FailedConnections InitiatedConnections} } } #Mos RDMA Connections - (Get-NetAdapterStatistics).RdmaStatistics | Select AcceptedConnections, ActiveConnections, InitiatedConnections #ConnectionCountPerRdmaNetworkInterface function get-ConnectionCountPerRdmaNetworkInterface { if ((Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters | Select-Object -Property *) -match "ConnectionCountPerRdmaNetworkInterface") { $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } else { Write-Host "Key is not present in registry " } } function set-ConnectionCountPerRdmaNetworkInterface ($value) { if ((Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters | Select-Object -Property *) -match "ConnectionCountPerRdmaNetworkInterface") { Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -Verbose -Force $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } else { Write-Host "Key is not present in registry. Defining.. " New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -PropertyType Dword -Verbose $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } } function netusedelete { net use * /d /y; ActiveConnections} function netsharedelete { Get-SmbShare -Name ram* | % { Remove-SmbShare -Name $_.Name -Force -Verbose } } #New-Alias -Name smbConnection -Value Get-SMBMultiChannelConnection function smbConnection ($RunOnPeerAsWell) { Get-SmbMultichannelConnection if($RunOnPeerAsWell) { Write-Host `nGetting smb connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; smbConnection} } } function smbUpdate ($RunOnPeerAsWell,$Run_X_times_in5SecInterval) { Update-SmbMultichannelConnection smbConnection ActiveConnections if($Run_X_times_in5SecInterval) { } if($RunOnPeerAsWell) { Write-Host `nUpdating smb connections on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; smbUpdate} } } #Write function to check for pfc frames per second function RDMAStats() { param( [Parameter(Mandatory = $false)] [ValidateSet('MBps', 'Gbps')] $Unit="Gbps", [Parameter(Mandatory = $false)]$IncludeHypervInterfaces ) #For all adapters $j = 0 while (1) { if ($IncludeHypervInterfaces) { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps'| Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } else { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps'| Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } #Write-Host $adapterList $i = 0 $count = $adapterList.Count #Write-Host $count if ($j % 10 -eq 0) { while ($i -lt $count) { Write-Host $adapterList[$i] `t`t`t`t -NoNewLine -ForegroundColor Yellow $i++ } Write-Host `n $i = 0 while ($i -lt $count) { Write-Host Inbound`t`t OutBound`t -NoNewLine -ForegroundColor DarkCyan $i++ } } $j++ Write-Host `n $i = 0 while ($i -lt $count) { if ($Unit -eq 'MBps') { $a = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]).RdmaStatistics #Write-Host $adapterList[$i] Start-Sleep 1 $b = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]).RdmaStatistics $inbound = [math]::Round((($b.InboundBytes - $a.InboundBytes) / 1MB), 2) $outbound = [math]::Round((($b.OutboundBytes - $a.OutboundBytes) / 1MB), 2) #Write-Host $adapterList[$i] `t -NoNewLine Write-Host $inbound MBps - $outbound MBps `t -NoNewLine $i++ } elseif ($Unit -eq 'Gbps') { $a = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]).RdmaStatistics #Write-Host $adapterList[$i] Start-Sleep 1 $b = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]).RdmaStatistics $inbound = [math]::Round((($b.InboundBytes - $a.InboundBytes)*8/1000000000), 2) $outbound = [math]::Round((($b.OutboundBytes - $a.OutboundBytes)*8/1000000000), 2) #Write-Host $adapterList[$i] `t -NoNewLine Write-Host $inbound Gbps - $outbound Gbps `t -NoNewLine $i++ } } Write-Host `n } } function RDMAStats2() { param( [Parameter(Mandatory = $false)] [ValidateSet('MBps', 'Gbps')] $Unit, [Parameter(Mandatory = $false)]$IncludeHypervInterfaces, $maxSamples = 5 ) #For all adapters $j = 0 $samples = 1 while ($samples -le $maxSamples) { if ($IncludeHypervInterfaces) { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, *hyper* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps'| Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } else { #Explicitely declared as array since it wont work on a single port adapter. as for only single port, the string that it returns will be considered as string which itself is an array. So $adapterList[0] will return first letter of InterfaceAlias and so on [string[]]$adapterList = ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps'| Where-Object -Property Status -NE 'Disabled') | Where-Object -Property LinkSpeed -ne '1 Gbps').Name } #Write-Host $adapterList $i = 0 $count = $adapterList.Count #Write-Host $count if ($j % 10 -eq 0) { while ($i -lt $count) { Write-Host $adapterList[$i] `t`t`t`t -NoNewLine -ForegroundColor Yellow $i++ } Write-Host `n $i = 0 while ($i -lt $count) { Write-Host Inbound`t`t OutBound`t -NoNewLine -ForegroundColor DarkCyan $i++ } } $j++ Write-Host `n $i = 0 while ($i -lt $count) { if ($Unit -eq 'MBps') { $intDesc = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]) $inboundStats= typeperf "\RDMA Activity($intDesc)\RDMA Inbound Bytes/sec" -sc 1 $outboundStats= typeperf "\RDMA Activity($intDesc)\RDMA Outbound Bytes/sec" -sc 1 $inboundStats = [math]::Round(([decimal]((($inboundStats[2] -split(","))[1]).trim('"')))*8/1000000000,2) $outboundStats = [math]::Round(([decimal]((($outboundStats[2] -split(","))[1]).trim('"')))*8/1000000000,2) Write-Host $inboundStats MBps - $outboundStats MBps `t -NoNewLine $i++ } elseif ($Unit -eq 'Gbps') { $intDesc = (Get-NetAdapterStatistics -InterfaceAlias $adapterList[$i]) $inboundStats= typeperf "\RDMA Activity($intDesc)\RDMA Inbound Bytes/sec" -sc 1 $outboundStats= typeperf "\RDMA Activity($intDesc)\RDMA Outbound Bytes/sec" -sc 1 $inboundStats = [math]::Round(([decimal]((($inboundStats[2] -split(","))[1]).trim('"')))*8/1000000000,2) $outboundStats = [math]::Round(([decimal]((($outboundStats[2] -split(","))[1]).trim('"')))*8/1000000000,2) Write-Host $inboundStats MBps - $outboundStats Gbps `t -NoNewLine $i++ } } $samples++ Write-Host `n } } ################################################VF RDMA#################################################################### function RDMAWeight ($value, $vmName, $networkAdaterName) { if ($vmName) { if ($networkAdaterName) { if ($value -or ($value -eq 0)) { Set-VmNetworkAdapterRdma -VMName $vmName -RDMAWeight $value -Verbose -VmNetworkAdapterAdapterName $networkAdaterName } else { Get-VmNetworkAdapterRDMA -VMName $vmName -VMNetworkAdapterName $networkAdaterName } } } else { if ($value -or ($value -eq 0)) { Set-VmNetworkAdapterRdma -VMName $vmName -RDMAWeight $value -Verbose -VmNetworkAdapterAdapterName * } else { Get-VmNetworkAdapterRDMA -VMName $vmName -VMNetworkAdapterName * } } if ($value -or ($value -eq 0)) { Set-VmNetworkAdapterRDMA -VMName * -RDMAWeight $value -Verbose } else { Get-VmNetworkAdapterRDMA -VMName * } } function Get-VF-RDMA-VFCount { Write-host "`nVFs are considered RDMA capable once they match with these resourse counts - MaxCompletionQueueCount>=64 and MaxMemoryRegionCount=4095 and MaxProtectionDomainCount>=32 and last MaxQueuePairCount>=32`n" -ForegroundColor Yellow $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $totalVfCount = 0 $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name | Sort-Object foreach ($vmName in $vmNames) { Write-Host Starting job on $vmName $Session = New-PSSession -VMName $vmName -Credential $cred $temp = Invoke-Command -Session $Session -ScriptBlock { Write-Host RDMA capable VFs from $args -ForegroundColor Cyan [string[]]$adapterList = (Get-NetAdapterRdma -InterfaceDescription *Qlogic*,*Marvell*,*HPE* | where MaxCompletionQueueCount -ge 64 | where MaxMemoryRegionCount -eq 4095 | where MaxProtectionDomainCount -ge 32 | where MaxQueuePairCount -ge 32).InterfaceDescription if($adapterList -eq $null){Write-Host None} else{Write-host $adapterList -Separator `n} return $adapterList.Length } -ArgumentList $vmName -AsJob # Invoke-Command -Authentication Negotiate }#Foreach of all VMs Get-Job | Wait-Job -Timeout 300 -Verbose | %{ $totalVfCount = $totalVfCount + $(Receive-Job -Id $_.Id)} Get-Job | Remove-Job -Force #Final Write-host Total RDMA capable VFs $totalVfCount -ForegroundColor GREEN } function Get-VF-RDMA-Statistics { $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $totalVfCount = 0 #$vmCount=(get-vm).count $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name | Sort-Object #$vmNames = "vm-1","vm-2" foreach ($vmName in $vmNames) { Write-Host Starting Job on $vmName -ForegroundColor Cyan $Session = New-PSSession -VMName "$vmName" -Credential $cred $temp = Invoke-Command -Session $Session -ScriptBlock { $vmVfCount = 0 write-host VF RDMA statisticks from $args ... -BackgroundColor Red #check stats only on RDMA capable VNICS #$adapterList = Get-NetAdapterRdma -InterfaceDescription *Qlogic*,*Marvell*,*HPE* | where MaxCompletionQueueCount -ge 64 | where MaxMemoryRegionCount -eq 4095 | where MaxProtectionDomainCount -ge 32 | where MaxQueuePairCount -ge 32 [string[]]$adapterList = Get-NetAdapterRdma -InterfaceDescription *Qlogic*,*Marvell*,*HPE* | where MaxCompletionQueueCount -ge 64 | where MaxMemoryRegionCount -eq 4095 | where MaxProtectionDomainCount -ge 32 | where MaxQueuePairCount -ge 32 | % { Write-host Checking stats for $_.Name $_.InterfaceDescription - -ForegroundColor Cyan; $getStats = (Get-NetAdapterStatistics -Name $_.Name).RdmaStatistics; Write-Host "Active-Connections:" ($getStats).ActiveConnections; Write-Host "Initiated-Connections:" ($getStats).InitiatedConnections; Write-Host "Accepted-Connections:" ($getStats).AcceptedConnections; Write-Host "Failed-Connections:" ($getStats).FailedConnectionAttempts; Write-Host "CompletionQueueErrors:" ($getStats).CompletionQueueErrors; #For now, the logic is like if active connections are more then 0 then its running traffic + Plus putting the stats below #if (($getStats).ActiveConnections -gt 0) { $vmVfCount++ } $getStats = (Get-NetAdapterStatistics -Name $_.Name).RdmaStatistics $inStats1 = ($getStats).InboundBytes; $outStats1 = ($getStats).OutboundBytes; Sleep 1; $getStats = (Get-NetAdapterStatistics -Name $_.Name).RdmaStatistics $inStats2 = ($getStats).InboundBytes; $outStats2 = ($getStats).OutboundBytes; Write-Host Considered traffic is running if difference is greater than 1000000 bytes #For now VM VF count is incremented when only Rx traffic $inStats = $inStats2 - $inStats1 $outStats = $outStats2 - $outStats1 $inStatsGb = [math]::Round((($inStats)*8/1000000000), 2) $outStatsGb = [math]::Round((($outStats)*8/1000000000), 2) if ($inStats -gt 1000000) { Write-Host Rx Traffic running - Stats $inStatsGb Gbps - Before $inStats1 After $inStats2 -ForegroundColor GREEN} else { Write-Host NO Rx Traffic running - Stats Before $inStats1 After $inStats2 -ForegroundColor RED } if ($outStats -gt 1000000) { Write-Host Tx Traffic running - Stats $outStatsGb Gbps - Before $outStats1 After $outStats2 -ForegroundColor GREEN } else { Write-Host NO Tx Traffic running - Stats $outStatsGb Gbps - Before $outStats1 After $outStats2 `n -ForegroundColor RED } if(($inStats -gt 1000000) -or ($outStats -gt 1000000)){$vmVfCount++} }#Foreach Adapter in VM Write-host RDMA Running on $vmVfCount VFs -ForegroundColor Magenta return $vmVfCount } -ArgumentList $vmName -AsJob # Invoke-Command -Authentication Negotiate }#Foreach of all VMs $totalVfCount = 0 ; Get-Job | Wait-Job -Timeout 300 -Verbose | %{ $totalVfCount = $totalVfCount + $(Receive-Job -id $_.Id) } Remove-Job * -Force Write-host RDMA running on total $totalVfCount VFs -ForegroundColor GREEN } ############################################################# VF RDMA END ############################################# ##############################################################QoS###################################################### function dcbRole { Get-WindowsFeature -Name "*Bridg*" $a = Get-WindowsFeature -Name "*Bridg*" | select installed if ($a -match 'False') { Write-Host `n DCB Role is not installed.... -Foregroundcolor "RED" $input = Read-Host -Prompt 'Would you like to install [yes/no]' if (($input -eq 'yes') -or ($input -eq 'y')) { Install-WindowsFeature -Name 'Data-Center-Bridging'; Install-WindowsFeature -Name 'RSAT-DataCenterBridging-LLDP-Tools' } } } function noDcbRole { Remove-WindowsFeature 'Data-Center-Bridging', 'RSAT-DataCenterBridging-LLDP-Tools' } function Get-lldp ($restartWireSharkService) { if (Test-Path "C:\Program Files\Wireshark\tshark.exe") { if($restartWireSharkService) { #Restarting the npf service to refresh the device list in wireshark Restart-Service npcap -Verbose -Force -ErrorAction SilentlyContinue Restart-Service npf -Verbose -Force -ErrorAction SilentlyContinue sleep 5 } ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Write-Host Getting LLDP on $_.InterfaceAlias - $_.InterfaceDescription -ForegroundColor Cyan $output = tshark.exe -O lldp -f "ether proto 0x88cc" -c 1 -i $_.InterfaceAlias -a duration:70 if ($output -eq "") { Write-Host No LLDP received till 70 seconds } else { $output } } } else { Write-Host Please install wireshark. } } function dis-qos { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Disable-NetAdapterQos -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } function en-qos { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Enable-NetAdapterQos -InterfaceAlias $_.InterfaceAlias -Verbose -Confirm:0 } } function qos ($RunOnPeerAsWell) { Get-NetAdapterQos if($RunOnPeerAsWell) { Write-Host Getting QoS Setting on $(Get-PeerIp) Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Get-NetAdapterQos} } } function dcbxsettings ($RunOnPeerAsWell) { Get-NetQosDcbxSetting if($RunOnPeerAsWell) { Write-Host DCBX Setting on $(Get-PeerIp) Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Get-NetQosDcbxSetting} } } Function willing ($RunOnPeerAsWell) { Set-NetQosDcbxSetting -Willing 1 -Confirm:0 -Verbose if($RunOnPeerAsWell) { Write-Host Setting willing mode on $(Get-PeerIp) Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; willing} } } Function nonwilling ($RunOnPeerAsWell) { Set-NetQosDcbxSetting -Willing 0 -Confirm:0 -Verbose if($RunOnPeerAsWell) { Write-Host Setting willing mode on $(Get-PeerIp) Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; nonwilling} } } New-Alias -Name tc -Value "Get-NetQosTrafficClass" function tcNew($name, $bandwidth, $priority) { New-NetQosTrafficClass -Name $name -Algorithm ETS -BandwidthPercentage $bandwidth -priority $priority -Verbose } function tcSet($name, $bandwidth, $priority) { Set-NetQosTrafficClass -Name $name -Algorithm ETS -BandwidthPercentage $bandwidth -Verbose -priority $priority } Function qfc ($priority) { if($priority){Enable-NetQosFlowControl -Priority $priority -Verbose} else{Get-NetQosFlowControl} } Function policy { Get-NetQosPolicy -PolicyStore ActiveStore } Function policy_smb ($priority) { New-NetQosPolicy -PolicyStore ActiveStore -Name smb -PriorityValue8021Action $priority -NetDirectPortMatchCondition 445 } Function policy_smb_set ($priority) { Set-NetQosPolicy -PolicyStore ActiveStore -Name smb -PriorityValue8021Action $priority -NetDirectPortMatchCondition 445 } Function policy_nic ($priority) { New-NetQosPolicy -PolicyStore ActiveStore -Name nic -IPProtocolMatchCondition tcp -PriorityValue8021Action $priority -Verbose } Function policy_iscsi ($priority) { New-NetQosPolicy -PolicyStore ActiveStore -Name iSCSI -PriorityValue8021Action $priority -iSCSI -Verbose } Function policy_foce ($priority) { New-NetQosPolicy -PolicyStore ActiveStore -Name FOCE -PriorityValue8021Action $priority -FCOE -Verbose } Function nopolicy { Remove-NetQosPolicy * -PolicyStore ActiveStore -Verbose -Confirm:0 } function nofc { 0..7 | % { Disable-NetQosFlowControl -Priority $_ -Verbose } } Function notc ($TrafficClassName) { if ($TrafficClassName) { Remove-NetQosTrafficClass $TrafficClassName -Confirm:0 -Verbose } else { Remove-NetQosTrafficClass * -Verbose -Confirm:0 } } function nopfcConfig() { willing nofc notc nopolicy } function pfcConfig() { nonwilling qfc 4 tcnew r 50 4 policy_smb 4 policy_foce 3 policy_iscsi 1 sleep 3 qos } function tlv { policy_smb 4 policy_foce 3 policy_iscsi 1 } ################################################################QOS_END################################################################# ########## General Adapter and OS configuration Commands#### function Get-SwitchPorts ($restartWireSharkService) { if (Test-Path "C:\Program Files\Wireshark\tshark.exe") { if($restartWireSharkService) { #Restarting the npf service to refresh the device list in wireshark Restart-Service npcap -Verbose -Force -ErrorAction SilentlyContinue Restart-Service npf -Verbose -Force -ErrorAction SilentlyContinue sleep 5 } ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Write-Host Getting LLDP on $_.InterfaceAlias - $_.InterfaceDescription -ForegroundColor Cyan tshark.exe -O lldp -f "ether proto 0x88cc" -c 1 -i $_.InterfaceAlias | Select-String -Pattern "Port Subtype =", "System Name =", "System Description =", "Chassis Id:", "Management Address:" } } else { Write-Host Please install wireshark. } } function Drivers ($displayTimeStamps, $RunOnPeerAsWell) { Write-Host "Components:" -ForegroundColor Magenta $OS = (Get-WmiObject win32_operatingsystem).Caption #$driverLetter = (Get-Partition | Where-Object IsBoot -eq $True).DriveLetter #$ProductVersion=(get-item $driverLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #For W2012R2 and W2012 as GetPnpDevice doesnt work on these OSes if ($OS -match "Microsoft Windows Server 2012") { $driverType = "" if ((Get-Device | where -Property Service -eq 'qebdrv' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qevbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp= " - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-Device | where -Property Service -eq 'l2nd2' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qenda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp= " - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-Device | where -Property Service -eq 'qefcoe' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qefcoe.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp= " - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-Device | where -Property Service -eq 'qeois' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qeois.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp= " - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } } #if block else { #for WS2016 and WS2019 #display sys file version only when drivers are installed $driverType = "" #Write-Host in else if ((Get-PnpDevice | where -Property Service -eq 'qebdrv' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qevbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp= " - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-PnpDevice | where -Property Service -eq 'l2nd2' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qenda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp=" - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-PnpDevice | where -Property Service -eq 'qefcoe' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qefcoe.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp=" - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } if ((Get-PnpDevice | where -Property Service -eq 'qeois' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\qeois.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } if($displayTimeStamps){$timestamp=" - Driver TimeStamp - " + $_.LastWriteTime} Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType $timestamp } } }#else block #Dont print mfw version in case of VMs if ((Get-WmiObject -Class Win32_computersystem).model -ne "Virtual Machine") { #Getting MFW/Board/Rev $str = ediag -param exit (($str | Select-String -Pattern MFW) -split ' ')[2] #Getting Board #Spilt "`n" to remove/trim newlines $board = ((($str) | Select-String -Pattern Board) -split "`n" ) $boardRevision = (($str | Select-String -Pattern Rev) -split " ")[1] $asic = (($str | Select-String -Pattern Rev) -split " ")[0] Write-Host $board $asic $boardRevision OS $a = Get-CimInstance Win32_ComputerSystem | select Name, Manufacturer, Model $Manufacturer = $a.Manufacturer + $a.Model $b = Get-CimInstance Win32_BIOS $SerialNumber = $b.SerialNumber $ServerBIOS = $b.SMBIOSBIOSVersion + $b.ReleaseDate Write-Host "System: $Manufacturer BIOS - $ServerBIOS $ServerBIOSDate Serial Number - $SerialNumber" Write-host "`n" } if($RunOnPeerAsWell) { Write-Host `nGetting drivers on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; drivers -displayTimeStamps $args[0]} -ArgumentList $displayTimeStamps } } function Get-DriverSymbols2 { param( $VBDVersion, $NDISVersion, [ValidateSet("retail_x86-64", "checked_x86-64")]$driverType ) #For NDIS if ((Test-Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$NDISVersion\qlgc\$driverType\sym\private\qenda.pdb)) { if (!(Test-Path C:\EIT_Drivers\Symbols)) { mkdir C:\EIT_Drivers\Symbols } else {Remove-Item C:\EIT_Drivers\Symbols\q* -Verbose} Copy-item "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$NDISVersion\qlgc\$driverType\sym\private\qenda.pdb" "C:\EIT_Drivers\Symbols\" -Force -Verbose -Confirm:0 -PassThru } else { Write-host \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$NDISVersion\qlgc\$driverType\sym\private\qenda.pdb not found } #For VBD if ((Test-Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$VBDVersion\qlgc\$driverType\sym\private\qevbda.pdb)) { if (!(Test-Path C:\EIT_Drivers\Symbols)) { mkdir C:\EIT_Drivers\Symbols } Copy-item "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$VBDVersion\qlgc\$driverType\sym\private\qevbda.pdb" "C:\EIT_Drivers\Symbols\" -Force -Verbose -Confirm:0 -PassThru } else { Write-host \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$VBDVersion\qlgc\$driverType\sym\private\qevbda.pdb not found } ii C:\EIT_Drivers\Symbols -ErrorAction SilentlyContinue } function Get-DriverSymbols { #For NDIS if ((Get-PnpDevice | where -Property Service -eq 'l2nd2') -ne $null) { Get-Item C:\Windows\System32\drivers\qenda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'checked_x86-64' } else { $driverType = 'retail_x86-64' } $driverVersion = $_.VersionInfo.FileVersion Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Test-Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$driverVersion\qlgc\$driverType\sym\private\qenda.pdb)) { if (!(Test-Path C:\EIT_Drivers\Symbols)) { mkdir C:\EIT_Drivers\Symbols } Copy-item "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$driverVersion\qlgc\$driverType\sym\private\qenda.pdb" "C:\EIT_Drivers\Symbols\" -Force } #For VBD if ((Get-PnpDevice | where -Property Service -eq 'qebdrv') -ne $null) { Get-Item C:\Windows\System32\drivers\qevbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'checked_x86-64' } else { $driverType = 'retail_x86-64' } $driverVersion = $_.VersionInfo.FileVersion Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Test-Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$driverVersion\qlgc\$driverType\sym\private\qevbda.pdb)) { if (!(Test-Path C:\EIT_Drivers\Symbols)) { mkdir C:\EIT_Drivers\Symbols } Copy-item "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$driverVersion\qlgc\$driverType\sym\private\qevbda.pdb" "C:\EIT_Drivers\Symbols\" -Force } ii C:\EIT_Drivers\Symbols -ErrorAction SilentlyContinue } function E3_Drivers { $OS = (Get-WmiObject win32_operatingsystem).Caption #$driverLetter = (Get-Partition | Where-Object IsBoot -eq $True).DriveLetter #$ProductVersion=(get-item $driverLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #For W2012R2 and W2012 as GetPnpDevice doesnt work on these OSes if (($OS -match "Microsoft Windows Server 2012") -or ($OS -match "Microsoft Windows Server 2012 R2")) { $driverType = "" if ((Get-Device | where -Property Service -eq 'ebdrv' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\evbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-Device | where -Property Service -eq 'l2nd' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxnd60a.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-Device | where -Property Service -eq 'bxfcoe' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxfcoe.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-Device | where -Property Service -eq 'bxois' | where -Property IsPresent -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxois.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } #Getting MFW # (((ediag -param exit) | Select-String -Pattern MFW) -split ' ')[2] #Getting Board # (ediag -param exit) | Select-String -Pattern Board } #if block else { #for WS2016 and WS2019 if ((Get-PnpDevice | where -Property Service -eq 'ebdrv' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\evbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-PnpDevice | where -Property Service -eq 'l2nd' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxnd60a.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-PnpDevice | where -Property Service -eq 'bxfcoe' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxfcoe.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } if ((Get-PnpDevice | where -Property Service -eq 'bxois' | where -Property Present -EQ $true) -ne $null) { Get-Item C:\Windows\System32\drivers\bxois.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } Write-Host $_.Name - $_.VersionInfo.FileVersion $driverType } } }#else block } function remove-nonpresent-devices { #DeviceManagement v1.0.3 #Get-Device -ShowNonpresentPresentDevices | Where-Object -Property IsPresent -eq $false if (!(Test-Path C:\softwares\remove-nonpresent-devices\removedevices.js)) { get remove-nonpresent-devices } cd C:\softwares\remove-nonpresent-devices .\removedevices.js /noconfirm cd \ } function noHiddenDevices { remove-nonpresent-devices } #Set WSUS function setParam { $Adapter = Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* #$b=Read-Host -Prompt "Select a single device for properties to read - " $a = Get-NetAdapterAdvancedProperty -Name "$Adapter[0].InterfaceAlias" | fl DisplayName, ValidDisplayValues $a #$a[0].DisplayName; #Get-NetAdapterAdvancedProperty -Name "slot 5 port 1" | Select-Object -Property DisplayName, ValidDisplayValues #Populate Param with the array $b #New-Variable -Name "var$i" -Value $i #Param( #[ValidateSet()]$Increment) } function SymbolsServer { Write-Host "\\qlogic.org\qidl_proj\bcm5710-symbols copied to clipboard, Just paste it"; Set-Clipboard -Value "\\qlogic.org\qidl_proj\bcm5710-symbols" } function corpip { Get-NetIPAddress | Where-Object -Property IPAddress -like "10.*" | Select IPAddress, InterfaceAlias, InterfaceIndex; set-Clipboard $((Get-NetIPAddress | Where-Object -Property IPAddress -like "10.*").IPAddress)} #ErrorAction SilentlyContinue used to avoid errors in Get-NetIPAddress when vswitch is created and no IP bindings are there on original interface #Get-NetAdapter | Where-Object -Property Status -ne Disconnected - Do not show IP for disconnected interfaces function getIpv4Addresses { (Get-NetAdapter | Where-Object -Property Status -ne Disconnected) | % { Get-NetIPAddress -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue -AddressFamily IPv4 | select IPAddress, InterfaceAlias, InterfaceIndex } } function getIpv6Addresses { (Get-NetAdapter | Where-Object -Property Status -ne Disconnected) | % { Get-NetIPAddress -InterfaceAlias $_.InterfaceAlias -ErrorAction SilentlyContinue -AddressFamily IPv6 | select IPAddress, InterfaceAlias, InterfaceIndex } } function Stats { ((Get-NetAdapter -InterfaceDescription *Marvell*, *25G*, *Qlogic*, HPE*, Mellanox* | Where-Object -Property InterfaceDescription -NOTLike *bcm5709* | Where-Object -Property InterfaceDescription -NOTLike *1Gb* | Where-Object -Property LinkSpeed -NE '100 Mbps' | Where-Object -Property LinkSpeed -NE '0 bps' | Where-Object -Property LinkSpeed -NE '1 Gbps') | Where-Object -Property LinkSpeed -ne '1 Gbps') | % { Write-host Checking stats for $_.Name $_.InterfaceDescription -ForegroundColor YELLOW; $a = (Get-NetAdapterStatistics -Name $_.Name).ReceivedBytes ; $a; Sleep 2; $b = (Get-NetAdapterStatistics -Name $_.Name).ReceivedBytes; $b; if (($b - $a) -ne 0) { Write-Host Rx Traffic running -ForegroundColor YELLOW } else { Write-Host NO Rx Traffic running -ForegroundColor RED } $a = (Get-NetAdapterStatistics -Name $_.Name).SentBytes; $a; Sleep 2; $b = (Get-NetAdapterStatistics -Name $_.Name).SentBytes; $b; if (($b - $a) -ne 0) { Write-Host Tx Traffic running -ForegroundColor YELLOW } else { Write-Host NO Tx Traffic running -ForegroundColor RED } Write-Host `n `n } } function MicrosoftDownloadShare {ii \\qidl-engr01-nas.qidl.na\win_sw\Microsoft} function MSFTShare {MicrosoftDownloadShare} function DevShare {MicrosoftDownloadShare} function SoftwareShare_EIT { ii \\10.30.35.10\Softwares\ -ErrorAction SilentlyContinue } function SoftwareShare_PQA { ii \\10.30.37.175\Softwares\ -ErrorAction SilentlyContinue } function SoftwareShare_USIrvine { ii \\10.104.217.102\Shares -ErrorAction SilentlyContinue } function usshare {SoftwareShare_USIrvine} function DriverShare_EIT { ii \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ -ErrorAction SilentlyContinue } function PerformanceData { rmdir -Path C:\PerformanceData\ -Recurse -Force -ErrorAction SilentlyContinue mkdir -Path c:\ -Name PerformanceData -Force Get-NetAdapterHardwareInfo | fl * > c:\PerformanceData\Get-NetAdapterHardwareInfo.log Get-ComputerInfo > C:\PerformanceData\Get-ComputerInfo.log #For Driver Versions Get-Item C:\Windows\System32\drivers\qevbda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' } $temp = $_.Name + "-" + $_.VersionInfo.FileVersion + " " + $driverType; $temp >>C:\PerformanceData\Drivers.log } Get-Item C:\Windows\System32\drivers\qenda.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }$temp = $_.Name + "-" + $_.VersionInfo.FileVersion + " " + $driverType ; $temp >>C:\PerformanceData\Drivers.log } Get-Item C:\Windows\System32\drivers\qefcoe.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }$temp = $_.Name + "-" + $_.VersionInfo.FileVersion + " " + $driverType; $temp >>C:\PerformanceData\Drivers.log } Get-Item C:\Windows\System32\drivers\qeois.sys | % { if ($_.VersionInfo.IsDebug) { $driverType = 'DBG' } else { $driverType = 'Retail' }$temp = $_.Name + "-" + $_.VersionInfo.FileVersion + " " + $driverType; $temp >>C:\PerformanceData\Drivers.log } #Getting MFW (((ediag -param exit) | Select-String -Pattern MFW) -split ' ')[2] >> C:\PerformanceData\Drivers.log #Getting Board (ediag -param exit) | Select-String -Pattern Board >> C:\PerformanceData\Drivers.log $computerInfo = Get-CimInstance Win32_ComputerSystem $zipName = $computerInfo.Name + "-" + $computerInfo.Model Compress-Archive -Path C:\PerformanceData\ -DestinationPath "C:\PerformanceData\$zipName.zip" ii C:\PerformanceData } function SystemInfo ($RunOnPeerAsWell) { drivers Write-Host "System Info:" -ForegroundColor Magenta $a = Get-CimInstance Win32_ComputerSystem | select Name, PartOfDomain, Domain, HypervisorPresent, Manufacturer, Model, NumberOfProcessors, NumberOfLogicalProcessors, TotalPhysicalMemory $Manufacturer = $a.Manufacturer + $a.Model #Round to next higher number using ceiling method, floor available for oppsite. $RAM = [MATH]::Ceiling($a.TotalPhysicalMemory / 1GB); $domain = $a.Domain + ", Part of Domain - " + $a.PartOfDomain $b = Get-CimInstance Win32_BIOS $SerialNumber = $b.SerialNumber $ServerBIOS = $b.SMBIOSBIOSVersion + $b.ReleaseDate $os = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name * $OsVersion = $os.ProductName + " " + $os.CurrentMajorVersionNumber + "." + $os.CurrentMinorVersionNumber + "." + $os.CurrentBuild + "." + $os.UBR Write-Host "`tSystem Model - $Manufacturer OS - $OsVersion Hostname - $($a.Name) Mgmt IP - $((corpip).IPAddress) ILO - $((Get-PcsvDevice -ErrorAction SilentlyContinue).IPv4Address) RAM - $RAM GB Server BIOS - $ServerBIOS $ServerBIOSDate Serial Number - $SerialNumber Hypervisor Present - $($a.HypervisorPresent) Domain - $domain Total Logical Processors - $($a.NumberOfLogicalProcessors)" Write-Host "`nProcessors Details:" -ForegroundColor Magenta processors if($RunOnPeerAsWell) { Write-Host `nGetting System Info of $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; SystemInfo} } } function dell-support-site { $b = Get-CimInstance Win32_BIOS $SerialNumber = $b.SerialNumber start https://www.dell.com/support/home/en-in/product-support/servicetag/$SerialNumber/drivers } function OS ($RunOnPeerAsWell){ $a = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name * $OS = $a.ProductName + " " + $a.CurrentMajorVersionNumber + "." + $a.CurrentMinorVersionNumber + "." + $a.CurrentBuild + "." + $a.UBR Write-Host OS: $OS #($OS = (Get-WmiObject win32_operatingsystem).Caption + " " + (get-item "c:\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion) #Set-Clipboard -Value "OS: $OS" if($RunOnPeerAsWell) { Write-Host `nOS on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; OS} } } function processors { Get-CimInstance Win32_Processor | Select Manufacturer, DeviceID, Name, L2CacheSize, L3CacheSize, MaxClockSpeed, NumberOfCores, NumberOfEnabledCore, NumberOfLogicalProcessors } function CPU_Usage { while (1) { Get-CimInstance Win32_Processor | % { Write-Host $_.DeviceID - $_.LoadPercentage; } Start-Sleep 1 cls } } function get-cpuUsage { #https://social.technet.microsoft.com/Forums/ar-SA/0435e7c5-3cda-41a0-953e-7fa462fde03b/perfmon-process-processor-time-vs-task-manager8217s-cpu-usage-for-monitoring-a-specific?forum=perfmon #see last #https://www.experts-exchange.com/questions/28939260/Difference-between-Processor-Time-and-Processor-Utility-Performance-Counters.html #https://superuser.com/questions/384554/whats-the-difference-between-processor-and-processor-information-in-perfmon-cou #more on perf - https://docs.microsoft.com/en-us/archive/blogs/winserverperformance/interpreting-cpu-utilization-for-performance-analysis $session = New-PSSession -ComputerName $(Get-PeerIp) -Credential $cred While(1) { #long type will automatically round it to next integer $cpuUsage= [long](((((typeperf "\Processor Information(_Total)\% Processor Utility" -sc 1)[2]) -split ",")[1]).trim('"')) $remote_cpuUsage = Invoke-Command -Authentication Negotiate -Session $session -ScriptBlock {[long](((((typeperf "\Processor Information(_Total)\% Processor Utility" -sc 1)[2]) -split ",")[1]).trim('"'))} Write-Host LOCAL CPU %: $cpuUsage `t REMOTE CPU %: $remote_cpuUsage } } function Dis-GlobalRss { netsh int tcp set global rss=disable netsh int tcp show global } function En-GlobalRss { netsh int tcp set global rss=enable netsh int tcp show global } ##############################################################Debugger and Debugging###################################################### #Set tracelog, copy to startup and system32 function Set-Verbosity ($dp_level, $dp_module) { $UserKey = "HKLM:\SYSTEM\CurrentControlSet\Services\qebdrv" New-ItemProperty -Path $UserKey -Name "dp_level" -Value $dp_level -Force -PropertyType STRING New-ItemProperty -Path $UserKey -Name "dp_module" -Value $dp_module -Force -PropertyType STRING New-ItemProperty -Path $UserKey -Name "dp_int_module" -Value $dp_module -Force -PropertyType STRING dbgView sleep 2 Dis-VBD; En-VBD } function Get-Verbosity { $UserKey = "HKLM:\SYSTEM\CurrentControlSet\Services\qebdrv" Get-ItemProperty -Path $UserKey -Name "dp_level" Get-ItemProperty -Path $UserKey -Name "dp_module" } function Remove-Verbosity { $UserKey = "HKLM:\SYSTEM\CurrentControlSet\Services\qebdrv" Remove-ItemProperty -Path $UserKey -Name "dp_level" -Force -Verbose -ErrorAction SilentlyContinue Remove-ItemProperty -Path $UserKey -Name "dp_module" -Force -Verbose -ErrorAction SilentlyContinue dbgView Dis-VBD; En-VBD } function tracelog-setup ($RunOnPeerAsWell) { $path = 'c:\windows\system32' $status = Copy-Item -Path "\\10.30.35.10\Softwares\roce_scripts\tracelog\tracelog.exe" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied tracelog.exe to $Path } Else { Write-Host tracelog.exe Copy Failed..!!! } $path = 'C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\' $status = Copy-Item -Path "\\10.30.35.10\Softwares\roce_scripts\tracelog\enable-trace.cmd" -Destination $path -Passthru -Recurse -Force If ($status) { Write-Host Copied enable-trace.cmd to $Path } Else { Write-Host enable-trace.cmd Copy Failed..!!! } & "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\enable-trace.cmd" if($RunOnPeerAsWell) { Write-Host `nSetting tracelog on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; tracelog-setup} } } #Function to get STACK and Network debug report from Memory dump windbg through command function Analyze-Dump () { [CmdletBinding()] param ( $dumpPath = "C:\windows\MEMORY.DMP", $getNetworkDebugReport = 0 ) $dumpTemp=Get-Item $dumpPath $dumpDirectory = $dumpTemp.Directory $logFile = [string] $dumpDirectory + "\" + [string] $dumpTemp.BaseName + ".log" $htmlFile = [string] $dumpDirectory + "\" + [string] $dumpTemp.BaseName + ".html" if(Test-Path $htmlFile){Remove-Item $htmlFile -Force -Verbose} if(!(Test-path "C:\Program Files\Windows Kits\10\Debuggers\x64\windbg.exe")){ windbg } Write-Host Dump generated at $dumpTemp.CreationTime Write-Host Geting driver symbols Get-DriverSymbols # $zipName = $computerInfo.Name + "-" + $computerInfo.Model # Compress-Archive -Path C:\PerformanceData\ -DestinationPath "C:\PerformanceData\$zipName.zip" # ii C:\PerformanceData cd "C:\Program Files\Windows Kits\10\Debuggers\x64" if($getNetworkDebugReport){ $command = "kb;!ndiskd.netreport -verbose -outputpath $htmlFile"} else{$command = "kb"} .\windbg -z $dumpPath -y "srv*C:\Symbols*http://msdl.microsoft.com/download/symbols;C:\EIT_Drivers\Symbols" -logo $logFile -c "$command" $input=Read-Host -Prompt "Rename Dump? Enter New Dump name or Hit ENTER to SKIP" if($input -ne "") { Rename-Item $dumpPath $input -Verbose Rename-Item $logFile "$input.log" -Verbose } ii $dumpDirectory } function Parse-Dump ($dumpPath) { if(!(Test-Path \\qlogic.org\qidl_proj\bcm5710sw_rel) -or !(Test-Path \\qlogic.org\qidl_proj\bcm5710sw_rel)) { Write-Host Please check whether \\qlogic.org\qidl_proj\bcm5710sw_rel or \\qlogic.org\il_proj\bcm5710sw_rel is accessible; break} $dumpTemp=Get-Item $dumpPath $dumpDirectory = $dumpTemp.Directory $parseDir = [string] $dumpDirectory + "\" + "ParsedData" $parseDir = New-Item $parseDir -ItemType Directory -Force Move-Item $dumpPath -Destination $parseDir $dumpTemp = Get-ChildItem $parseDir -Filter "*.dmp" | Get-Item $logFile = [string] $dumpDirectory + "\" + [string] $dumpTemp.BaseName + ".log" if(!(Test-path "C:\Program Files\Windows Kits\10\Debuggers\x64\windbg.exe")){ windbg } Write-Host Dump generated at $dumpTemp.CreationTime cd "C:\Program Files\Windows Kits\10\Debuggers\x64" $command = ".reload;!load E:\Windows_EIT_Drivers_E4_AH\b10kd\8.62.3.0\x86-x64\Release\b10kd.dll;kb;!dbg_tools combined_commands;q" Start-Process windbg.exe -Wait -ArgumentList "-z $dumpTemp -y `".sympath SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols;\\qlogic.org\qidl_proj\bcm5710-symbols;E:\dumps;$dumpDirectory`" -logo $logFile -c `"$command`"" Move-Item $dumpTemp.FullName $dumpDirectory -Verbose Compress-Archive -Path $parseDir -Verbose -DestinationPath $dumpDirectory\ParsedData.zip Remove-Item $parseDir -Force -Confirm:0 -Recurse <# $input=Read-Host -Prompt "Rename Dump? Enter New Dump name or Hit ENTER to SKIP" if($input -ne "") { Rename-Item $dumpPath $input } #> ii $dumpDirectory } #Function to check max vports, max queue pairs through ndiskd.dll function ndiskd_maxResourceCheck { if(!(Test-path "C:\Program Files\Windows Kits\10\Debuggers\x64\windbg.exe")){ windbg; Start-Sleep 10; } cd "C:\Program Files\Windows Kits\10\Debuggers\x64" .\windbg -kl -c "!load ndiskd.dll;!miniport" -y "srv*C:\OS_Symbols*http://msdl.microsoft.com/download/symbols;" } #Launch windbg function windbg ($port) { if(!(Test-Path 'C:\Program Files\Windows Kits\*\Debuggers\x64\windbg.exe')) { Start-Process '\\10.30.35.10\Softwares\windbg_2022\X64 Debuggers And Tools-x64_en-us.msi' -Wait Write-Host Associating WinDbg with the file extensions .dmp, .mdmp, and .wew in the registry -ForegroundColor Yellow Start-Process 'C:\Program Files\Windows Kits\*\Debuggers\x64\windbg.exe' -ArgumentList "-IAS" } if($port) { Set-Path "C:\Program Files\Windows Kits\10\Debuggers\x64" cd "C:\Program Files\Windows Kits\10\Debuggers\x64" New-Item -Path c:\ -Name Sagar -ItemType Directory -ErrorAction SilentlyContinue Start-Process windbg.exe -ArgumentList "-k net:port=${port},key=1.2.3.4 -y `"srv*C:\Symbols*http://msdl.microsoft.com/download/symbols;\\qlogic.org\qidl_proj\bcm5710-symbols;C:\EIT_Drivers\Symbols`" -logo c:\sagar\dbgLog_${port}.log" ii C:\Sagar } else { cd "C:\Program Files\Windows Kits\*\Debuggers\x64" & 'C:\Program Files\Windows Kits\*\Debuggers\x64\windbg.exe' } } #Launch kdnet function kdnet { cd "C:\Program Files\Windows Kits\*\Debuggers\x64" & 'C:\Program Files\Windows Kits\*\Debuggers\x64\kdnet.exe' } function debugView { if (!(Test-Path C:\Softwares\DebugView\Dbgview.exe)) { get debugview } if ((Test-Path C:\windows\system32\drivers\Dbgv.sys)) { Remove-Item C:\windows\system32\drivers\Dbgv2.sys -ErrorAction SilentlyContinue Rename-Item C:\windows\system32\drivers\Dbgv.sys dbgv2.sys -Force -Confirm:0 -Verbose } $logfile = "C:\dbgViewlog_$(Get-Random).log" Start-Process C:\Softwares\DebugView\Dbgview.exe -ArgumentList "/k /om /l $logfile" Write-Host Created log file - $logFile ii c:\ return $logfile } function dbgView {debugview} #notmyfault function notmyfault_crash ($RunOnPeerAsWell) { if(!(Test-Path C:\Softwares\NotMyFault\notmyfaultc64.exe)) { get NotMyFault } if($RunOnPeerAsWell) { Write-Host `nCrashing Peer -ForegroundColor RED Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Start-Process C:\Softwares\NotMyFault\notmyfaultc64.exe -ArgumentList "crash 0x1" ; } } Start-Process C:\Softwares\NotMyFault\notmyfaultc64.exe -ArgumentList "crash 0x1" } function debugOn { param( $hostip = "10.30.35.254" #In case of US setup using "10.104.217.223" as debugger hostip ) #Turning on DebuggerMode #Find Corp $corpInterface = Get-NetIPAddress | Where-Object -Property IPAddress -like "10.*" | Select IPAddress, InterfaceAlias, InterfaceIndex Write-Host Found Interfaces $corpInterface | fl * if($corpInterface -match "10.104.*"){Write-host 10.104 is US setup, using 10.104.217.223 as debugger host; $hostip = "10.104.217.223"} Write-host Selected interface - $corpInterface[0].InterfaceAlias with IP $corpInterface[0].IpAddress #Find bus number of corp $hardWareInfo = Get-NetAdapterHardwareInfo -InterfaceAlias $corpInterface[0].InterfaceAlias $busParams = [String]$hardWareInfo.BusNumber + '.' + [String]$hardWareInfo.Device + '.' + [String]$hardWareInfo.Function Write-Host Bus Params - $busParams #goto cmd mode for below commands $port = Read-Host -Prompt 'Enter Port Number - ' cmd /c bcdedit /set debug on cmd /c bcdedit /dbgsettings net hostip:$hostip port:$port key:1.2.3.4 cmd /c "bcdedit /set {dbgsettings} busparams $busParams" cmd /c bcdedit /dbgsettings #Putting registry key to allowFlowControlUnderDebugger Write-Host Updating Registry for allowFlowControlUnderDebugger New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\NDIS\Parameters -Name AllowFlowControlUnderDebugger -PropertyType DWORD -Value 1 } function debugOff { bcdedit /set debug off } #Displays current OS debugger settings function dbgsettings { if((bcdedit /enum "{current}") -contains "debug Yes") { Write-Host OS Debug is on } else { Write-Host OS Debug is off -ForegroundColor Red } bcdedit /dbgsettings } function set-dbgsettings {} function debugOnVM { param ( $port = 50001 ) #windbg $HostName = (Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\").GetValue("Hostname") $hostip = ([System.Net.Dns]::GetHostAddresses($HostName) | Where-Object IpAddressToString -match "10.").IpAddressToString #cd "C:\Program Files\Windows Kits\*\Debuggers\x64" #get kdnet \\10.30.35.10\Softwares\kdnet.exe $hostip $port cmd /c bcdedit /dbgsettings net hostip:$hostip port:$port key:1.2.3.4 #cmd /c "bcdedit /set {dbgsettings} busparams $busParams" dbgsettings #Putting registry key to allowFlowControlUnderDebugger Write-Host Updating Registry New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\NDIS\Parameters -Name AllowFlowControlUnderDebugger -PropertyType DWORD -Value 1 } function debugOnAllVMs ($startingPort) { $port = $startingPort $username = 'Administrator' $password = 'Qlogic01' $pass = ConvertTo-SecureString -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $pass $corpipaddress = (corpip).IpAddress $vmNames = (get-vm | Where-Object -Property State -eq 'Running').Name foreach ($temp in $VMNames) { Write-host Firing command in $temp Invoke-Command -VMName $temp -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; cmd /c bcdedit /set debug on cmd /c bcdedit /dbgsettings net hostip:$args[0] port:$args[1] key:1.2.3.4 cmd /c bcdedit /dbgsettings #Putting registry key to allowFlowControlUnderDebugger Write-Host Updating Registry New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\NDIS\Parameters -Name AllowFlowControlUnderDebugger -PropertyType DWORD -Value 1 } -Args $corpipaddress, $port $port++ }#foreach } #Function to get QP/vports from ndiskd from windbg through command ##############################################################Debugger and Debugging END###################################################### ###########################################################Drivers########################################################### #Copy Tool and Drivers function Install-VBD () { param( [string]$driverVersion, [Parameter(Mandatory = $true)] [ValidateSet("retail", "checked")]$driverType, #[ValidateSet("yes","no")]$Install_ex1_package $RunOnPeerAsWell ) #This line is to support remote installations net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { # if($Install_ex1_package -eq 'yes'){$package = 'qlgc_ex1'} # else{$package = 'qlgc'} $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport and bus drivers -Foregroundcolor "Magenta" #uninstall-Driver('all') Write-Host Installing driver qevbd\$item\qlgc\"$driverType"_x86-64\qevbd.inf <# ### Get and Install certificate to avoid dialog box $cert = (Get-AuthenticodeSignature $driver).SignerCertificate [System.IO.File]::WriteAllBytes("c:\QLogic.cer", $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)) $output = (certutil.exe -f -addstore "TrustedPublisher" c:\QLogic.cer) | Out-String write_log $myLogFile 0 $output Remove-Item -Path C:\qlogic.cer #> $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$item\qlgc\"$driverType"_x86-64\qevbd.inf if ($status -ne "") { Write-Host `n; $status; Write-Host VBD qlgc v$item installed successfully`n -Foregroundcolor "Green" } Else { Write-Host VBD qlgc v$item installation failed..!!! -Foregroundcolor "RED" } } else { <# Handle this failure, in this case $status is not blank Microsoft PnP Utility Processing inf : qend.inf Adding the driver package failed : A problem was encountered while attempting to add the driver to the store. Total attempted: 1 Number successfully imported: 0#> #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport and bus drivers -Foregroundcolor "Magenta" #uninstall-Driver('all') Write-Host Installing driver qevbd\$query\qlgc\"$driverType"_x86-64\qevbd.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$query\qlgc\"$driverType"_x86-64\qevbd.inf if ($status -ne "") { Write-Host `n; $status; Write-Host VBD qlgc v$query installed successfully`n -Foregroundcolor "Green" } Else { Write-Host VBD qlgc v$query installation failed..!!! -Foregroundcolor "RED" } } #remove-nonpresent-devices noHiddenDevices } } if($RunOnPeerAsWell) { Write-Host `nInstalling VBD driver v$driverVersion $driverType on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Install-VBD $args[0] $args[1]} -ArgumentList $driverVersion, $driverType } } New-Alias ivbd -Value Install-VBD function Install-FCOE () { param( [string]$driverVersion, [Parameter(Mandatory = $true)] [ValidateSet("retail", "checked")]$driverType, $RunOnPeerAsWell ) net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor "Magenta" #uninstall-Driver('qefcoe') Write-Host Installing driver ofc\$item\qlgc\"$driverType"_x86-64\qefcoe.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc\$item\qlgc\"$driverType"_x86-64\qefcoe.inf if ($status) { Write-Host `n; $status; Write-Host "FCOE Driver v$item installed successfully`n" -Foregroundcolor "Green" } Else { Write-Host "FCOE Driver v$item installation failed..!!!" -Foregroundcolor "RED" } } else { #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor "Magenta" #uninstall-Driver('qefcoe') Write-Host Installing driver ofc\$query\qlgc\"$driverType"_x86-64\qefcoe.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc\$query\qlgc\"$driverType"_x86-64\qefcoe.inf if ($status -ne "") { Write-Host `n; $status; Write-Host FCOE Driver v$query installed successfully -Foregroundcolor "Green" } Else { Write-Host FCOE Driver v$query installation failed..!!! -Foregroundcolor "RED" } } #remove-nonpresent-devices noHiddenDevices } } if($RunOnPeerAsWell) { Write-Host `nInstalling FCOE driver v$driverVersion $driverType on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Install-FCOE $args[0] $args[1]} -ArgumentList $driverVersion, $driverType } } New-Alias ifcoe -Value Install-FCOE function Install-iSCSI () { param( [string]$driverVersion, [Parameter(Mandatory = $true)] [ValidateSet("retail", "checked")]$driverType, $RunOnPeerAsWell ) net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor "Magenta" #uninstall-Driver('qeois') Write-Host Installing driver ois\$item\qlgc\"$driverType"_x86-64\qeois.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois\$item\qlgc\"$driverType"_x86-64\qeois.inf if ($status) { Write-Host `n; $status; Write-Host "iSCSI Driver v$item installed successfully`n" -Foregroundcolor "Green" } Else { Write-Host "iSCSI Driver v$item installation failed..!!!" -Foregroundcolor "RED" } } else { #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor "Magenta" #uninstall-Driver('qeois') Write-Host Installing driver ois\$query\qlgc\"$driverType"_x86-64\qeois.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois\$query\qlgc\"$driverType"_x86-64\qeois.inf if ($status -ne "") { Write-Host `n; $status; Write-Host iSCSI Driver v$query installed successfully -Foregroundcolor "Green" } Else { Write-Host iSCSI Driver v$query installation failed..!!! -Foregroundcolor "RED" } } #remove-nonpresent-devices noHiddenDevices } } if($RunOnPeerAsWell) { Write-Host `nInstalling iSCSI driver v$driverVersion $driverType on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Install-iSCSI $args[0] $args[1]} -ArgumentList $driverVersion, $driverType } } New-Alias iiscsi -Value Install-iSCSI function Install-NDIS () { param( [string]$driverVersion, [Parameter(Mandatory = $true)] [ValidateSet('retail', 'checked')]$driverType, #[ValidateSet("yes","no")]$Install_ex1_package $RunOnPeerAsWell ) net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path '\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend' -Name if ($driverVersion.Length -eq 0) { Write-Host 'Please input driver version (e.g. 8.33.9.0) or branch (8.33)' -Foregroundcolor 'RED' } Else { #if($Install_ex1_package -eq 'yes'){$package = 'qlgc_ex1'} #else{$package = 'qlgc'} $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor 'RED' } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor 'Magenta' #uninstall-Driver('l2nd2') #Write-Host Installing driver qend\$item\$package\"$driverType"_x86-64\qend.inf Write-Host Installing driver qend\$item\qlgc\"$driverType"_x86-64\qend.inf #$status=pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$item\$package\"$driverType"_x86-64\qend.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$item\qlgc\"$driverType"_x86-64\qend.inf if ($status) { Write-Host `n; $status; Write-Host "NDIS Driver v$item installed successfully`n" -Foregroundcolor 'Green' } Else { Write-Host "NDIS Driver v$item installation failed..!!!" -Foregroundcolor 'RED' } } else { #uninstalling any previous drivers, calling function uninstallDrivers #Write-Host Uninstalling any Previous miniport drivers -Foregroundcolor 'Magenta' #uninstall-Driver('l2nd2') #Write-Host Installing driver qend\$query\$package\"$driverType"_x86-64\qend.inf Write-Host Installing driver qend\$query\$package\"$driverType"_x86-64\qend.inf #$status=pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$query\$package\"$driverType"_x86-64\qend.inf $status = pnputil.exe /i /a \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$query\qlgc\"$driverType"_x86-64\qend.inf if ($status -ne '') { Write-Host `n; $status; Write-Host NDIS Driver v$query installed successfully -Foregroundcolor 'Green' } Else { Write-Host NDIS Driver v$query installation failed..!!! -Foregroundcolor 'RED' } } #remove-nonpresent-devices noHiddenDevices } } if($RunOnPeerAsWell) { Write-Host `nInstalling NDIS driver v$driverVersion $driverType on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Install-NDIS $args[0] $args[1]} -ArgumentList $driverVersion, $driverType } #For WS2022 sleep 5 Restore-Default } New-Alias indis -Value Install-NDIS function replace-sysfiles { param( $VBDVersion, $NDISVersion, [Parameter(Mandatory = $true)] [ValidateSet("retail", "checked")]$driverType, $disenVBD, $RunOnPeerAsWell # [ValidateSet("yes","no")]$Install_ex1_package ) if (!($VBDVersion) -and !($NDISVersion)) { Write-Host "Please input VBD and NDIS driver versions (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" return; } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username if($VBDVersion) { $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd" -Name $query = $a -match $VBDVersion If ($query.Length -eq 0) { Write-Host No VBD driver found with given Version - $VBDVersion -Foregroundcolor "RED" break; } Else { Write-host renaming old sys file to qevbda_old.sys del C:\Windows\System32\drivers\qevbda_old.sys -ErrorAction SilentlyContinue -Verbose -Force Rename-Item C:\Windows\System32\drivers\qevbda.sys qevbda_old.sys -Force -Confirm:0 -ErrorAction SilentlyContinue -Verbose If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $path = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$item\qlgc\$driverType" + "_x86-64\qevbda.sys" Copy-Item -Path $path -Destination C:\Windows\System32\drivers\ -Force -Recurse } else { $path = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$query\qlgc\$driverType" + "_x86-64\qevbda.sys" Copy-Item -Path $path -Destination C:\Windows\System32\drivers\ -Force -Recurse } } }#VBD Version if($NDISVersion) { #Check NDIS Drivers $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend" -Name if ($NDISVersion.Length -eq 0) { Write-Host "Please input NDIS driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { # if($Install_ex1_package -eq 'yes'){$package = 'qlgc_ex1'} # else{$package = 'qlgc'} Write-host renaming old sys file to qenda_old.sys del C:\Windows\System32\drivers\qenda_old.sys -ErrorAction SilentlyContinue -Verbose -Force Rename-Item C:\Windows\System32\drivers\qenda.sys qenda_old.sys -Force -Confirm:0 -ErrorAction SilentlyContinue -Verbose $query = $a -match $NDISVersion If ($query.Length -eq 0) { Write-Host No NDIS driver found with given Version - $NDISVersion -Foregroundcolor "RED" break; } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] $path = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$item\qlgc\$driverType" + "_x86-64\qenda.sys" Copy-Item -Path $path -Destination C:\Windows\System32\drivers\ -Force -Recurse } else { $path = "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$query\qlgc\$driverType" + "_x86-64\qenda.sys" Copy-Item -Path $path -Destination C:\Windows\System32\drivers\ -Force -Recurse } }#ElseBlock } }#NDISVersion if($disenVBD) { Dis-VBD En-VBD } #to check loaded drivers Write-Host Checking loaded drivers, you still have to reboot for the new replaced drivers to properly load. Drivers if($RunOnPeerAsWell) { Write-Host `nReplacing drivers sys files on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; replace-sysfiles -VBDVersion $args[0] -NDISVersion $args[1] -driverType $args[2]} -ArgumentList $VBDVersion, $NDISVersion,$driverType } }#main function uninstall-Driver { param( [Parameter(Mandatory = $true)] [ValidateSet("qebdrv", "l2nd2", "qefcoe", "qeois", "all", "netqend", "netqevbd", "l2nd", "ebdrv")]$service, $RunOnPeerAsWell ) if(!(Test-Path C:\Windows\System32\devcon.exe)) { get-devcon } if (!(Test-Path 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules')) { DeviceManagement } Write-Host uninstalling $service -ForegroundColor Yellow #keep devcon in below CD if ($service -eq 'all') { uninstall-Driver -service 'l2nd2' #uninstall-Driver -service 'netqend' uninstall-Driver -service 'qefcoe' uninstall-Driver -service 'qeois' uninstall-Driver -service 'qebdrv' #uninstall-Driver -service 'netqevbd' #check driver versions to make sure uninstallation drivers #remove-nonpresent-devices noHiddenDevices } else { $OS = (Get-WmiObject win32_operatingsystem).Caption #driverLetter = (Get-Partition | Where-Object IsBoot -eq $True).DriveLetter #$ProductVersion=(get-item $driverLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #For W2012R2 and W2012 as GetPnpDevice doesnt work on these OSes $dev = Get-Device | Where-Object Service -eq $service if($dev -eq $null) {Write-Host No $service Devices Present} else { #Add check here for FCOE (8.33.4.2) and ISCSI, as there provides for inbox also is Cavium and not MSFT if(($dev).DriverProvider -ne "Microsoft") { if ($dev -ne $null) { $dev = (Get-Device | Where-Object Service -eq $service) $oeminfpath = @() $oeminfpath += ($dev).AvailableProperties.DEVPKEY_Device_DriverInfPath if ($dev -ne $null) { foreach ($int in $dev) { [string]$pnpdevID = $int.InstanceId write-host "Uninstalling device `"$($int.Name)`"" -NoNewline $output = devcon.exe remove "@$pnpdevID" | Out-String if ($output -match "1 device") { Write-Host " - Uninstalled....." -ForegroundColor Green } else { Write-Host " - Failed to uninstall...." -ForegroundColor Red } } if (Test-Path -Path ("C:\windows\INF\" + $oeminfpath[0])) { Write-Host "Removing $oeminfpath" devcon.exe -f dp_delete $oeminfpath[0] Write-Host "Rescanning system..." devcon.exe rescan } } }#if }#Os if else { Write-Host Inbox v($dev.DriverVersion[0]) Present for $service`, skipped uninstallation }#inbox else }#$dev null else }#outmoest else if($RunOnPeerAsWell) { Write-Host `nUninstalling drivers on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; uninstall-Driver $args[0] } -ArgumentList $service } }#function #modify if else redundant code function uninstall-Driver-old () { param( [Parameter(Mandatory = $true)] [ValidateSet("qebdrv", "l2nd2", "qefcoe", "qeois", "all", "netqend", "netqevbd", "l2nd", "ebdrv")]$service ) if(!(Test-Path C:\Windows\System32\devcon.exe)) { get-devcon } #keep devcon in below CD if ($service -eq 'all') { uninstall-Driver -service 'l2nd2' #uninstall-Driver -service 'netqend' uninstall-Driver -service 'qefcoe' uninstall-Driver -service 'qeois' uninstall-Driver -service 'qebdrv' #uninstall-Driver -service 'netqevbd' sleep 5 #check driver versions to make sure uninstallation drivers #remove-nonpresent-devices noHiddenDevices } if ($service -eq 'e3') { #for E3 uninstall-Driver -service 'l2nd' uninstall-Driver -service 'ebdrv' #check driver versions to make sure uninstallation E3_Drivers #remove-nonpresent-devices noHiddenDevices } else { $OS = (Get-WmiObject win32_operatingsystem).Caption #driverLetter = (Get-Partition | Where-Object IsBoot -eq $True).DriveLetter #$ProductVersion=(get-item $driverLetter":\Windows\system32\ntoskrnl.exe").VersionInfo.ProductVersion #For W2012R2 and W2012 as GetPnpDevice doesnt work on these OSes if ($OS -notmatch "Microsoft Windows Server 2012") { $dev = (Get-PnpDevice | Where-Object Service -eq $service) if ($dev -ne $null) { foreach ($int in $(Get-PnpDevice | Where-Object { $_.Service -eq $service })) { $oeminfpath = Get-PnpDeviceProperty -InstanceId $int.instanceid -KeyName DEVPKEY_Device_DriverInfPath [string]$pnpdevID = $int.PnPDeviceID [string]$infName = $oeminfpath.Data write-host "Uninstalling device `"$($int.FriendlyName)`"" $output = devcon.exe remove "@$pnpdevID" | Out-String if ($output -match "1 device") { Write-Host Done..... } else { Write-Host Fail.... } } if (Test-Path -Path ("C:\windows\INF\" + $infName)) { Write-Host "Removing $infName" devcon.exe -f dp_delete $infName Write-Host "Rescanning system..." devcon.exe rescan } }#if }#Os if else { $dev = (Get-Device | Where-Object Service -eq $service) $oeminfpath = ($dev).AvailableProperties.DEVPKEY_Device_DriverInfPath if ($dev -ne $null) { foreach ($int in $dev) { [string]$pnpdevID = $int.InstanceId write-host "Uninstalling device `"$($int.Name)`"" $output = devcon.exe remove "@$pnpdevID" | Out-String if ($output -match "1 device") { Write-Host Done..... } else { Write-Host Fail.... } } if (Test-Path -Path ("C:\windows\INF\" + $oeminfpath[0])) { Write-Host "Removing $infName" devcon.exe -f dp_delete $oeminfpath[0] Write-Host "Rescanning system..." devcon.exe rescan } }#else #Write-Host `nWaiting 10 seconds to check if any previous driver loads `(earlier driver upgrade sceanario`) #Sleep 10 #Testing if drivers uninstalled successfully, like in case of upgrade devices will reappear with older drivers #uninstall-Driver -Service $service }#else #Check driver version after uninstallation #drivers #E3_Drivers }#outmoest else }#function function get-FCOE ($driverVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\ofc' $a = Test-Path $path If (!$a) { new-item $path -ItemType Directory -Verbose } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc\$item -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied FCOE Driver v$item to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "FCOE Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } else { Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ofc\$query -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied FCOE Driver v$query to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "FCOE Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } } } if($RunOnPeerAsWell) { Write-Host `nCopying FCOE driver on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-FCOE -driverVersion $args[0] } -ArgumentList $driverVersion } } function get-iSCSI ($driverVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\ois' $a = Test-Path $path If (!$a) { new-item $path -ItemType Directory -Verbose } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois\$item -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied FCOE Driver v$item to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "iSCSI Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } else { Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ois\$query -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied FCOE Driver v$query to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "iSCSI Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } } } if($RunOnPeerAsWell) { Write-Host `nCopying iSCSI driver on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-iSCSI -driverVersion $args[0] } -ArgumentList $driverVersion } } function get-Vbd ($driverVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\qevbd' $a = Test-Path $path If (!$a) { new-item $path -ItemType Directory -Verbose } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$item -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Bus Driver v$item to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "Bus Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } else { Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qevbd\$query -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Bus Driver v$query to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "Bus Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } } } if($RunOnPeerAsWell) { Write-Host `nCopying VBD driver on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-Vbd -driverVersion $args[0] } -ArgumentList $driverVersion } } function get-NDIS ($driverVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\qend' $a = Test-Path $path If (!$a) { new-item $path -ItemType Directory -Verbose } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input driver version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No driver found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$item -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Bus Driver v$item to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "NDIS Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } else { Write-Host Copying driver... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\qend\$query -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Bus Driver v$query to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "NDIS Driver v$item copy failed..!!!" -Foregroundcolor "RED" } } } } if($RunOnPeerAsWell) { Write-Host `nCopying NDIS driver on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-NDIS -driverVersion $args[0] } -ArgumentList $driverVersion } } function get-CD { $Sourcepath = 'c:\EIT_Drivers\CD' $TargetPath = '\\10.30.35.254\Windows_EIT_Drivers_E4_AH\CD' $a = Test-Path $Sourcepath If (!$a) { new-item $Sourcepath -ItemType Directory -Verbose } ii $Sourcepath ii $TargetPath } function upgrade-FCOE { } function upgrade-vbd { } ####################################################################ediag######################################################################## function get-ediag ($driverVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\ediag' $a = Test-Path $path If (!$a) { new-item $path -ItemType Directory -Verbose } else { rmdir $path\* -Recurse -Force } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\ediag" -Name if ($driverVersion.Length -eq 0) { Write-Host "Please input diag version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match $driverVersion If ($query.Length -eq 0) { Write-Host No diag found with given Version - $driverVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying diag... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ediag\$item -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Diag v$item to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "Diag v$item copy failed..!!!" -Foregroundcolor "RED" } } else { Write-Host Copying diag... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\ediag\$query -Destination $path -Recurse -Force -Passthru if ($status) { Write-Host Copied Diag v$query to $Path -Foregroundcolor "Green"; ii $path -ErrorAction SilentlyContinue } Else { Write-Host "Diag v$item copy failed..!!!" -Foregroundcolor "RED" } } } } if($RunOnPeerAsWell) { Write-Host `nCopying ediag on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-ediag -driverVersion $args[0] } -ArgumentList $driverVersion } } function get-mfw ($mfwVersion, $RunOnPeerAsWell) { $path = 'c:\EIT_Drivers\ediag' $a = Test-Path $path If (!$a) { Write-Host "No Ediag Present, Get ediag using get-ediag <branch> command, for now copying ediag 8.60.23.0 to c:\EIT_Drivers\ediag" get-ediag 8.60.23.0 } net use \\10.30.35.254\Windows_EIT_Drivers_E4_AH $global:password /USER:$global:username $a = Get-ChildItem -Path "\\10.30.35.254\Windows_EIT_Drivers_E4_AH\mfw" -Name if ($mfwVersion.Length -eq 0) { Write-Host "Please input mfw version (e.g. 8.33.9.0) or branch (8.33)" -Foregroundcolor "RED" } Else { $query = $a -match "$mfwVersion" If ($query.Length -eq 0) { Write-Host No mfw found with given Version - $mfwVersion -Foregroundcolor "RED" } Else { If ($query.count -gt 1) { for ($i = 1; $i -le $query.Count; $i++) { Write-Host $i. $query[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $query[$itemNumber - 1] Write-Host Copying mfw... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\mfw\$item -Destination (Get-ChildItem -Path $path -Directory)[0].FullName -Recurse -Force -Passthru if ($status) { Write-Host Copied mfw v$item to (Get-ChildItem -Path $path -Directory)[0].FullName -Foregroundcolor "Green"; #ii (Get-ChildItem -Path $path -Directory)[0].FullName -ErrorAction SilentlyContinue } Else { Write-Host "mfw v$item copy failed..!!!" -Foregroundcolor "RED" } Set-Clipboard -Value "nvm upgrade -F -mfw $item" -Verbose ediag } else { Write-Host Copying mfw... $status = Copy-Item -Path \\10.30.35.254\Windows_EIT_Drivers_E4_AH\mfw\$query -Destination (Get-ChildItem -Path $path -Directory)[0].FullName -Recurse -Force -Passthru if ($status) { Write-Host Copied mfw v$query to (Get-ChildItem -Path $path -Directory)[0].FullName -Foregroundcolor "Green"; #ii (Get-ChildItem -Path $path -Directory)[0].FullName -ErrorAction SilentlyContinue } Else { Write-Host "mfw v$query copy failed..!!!" -Foregroundcolor "RED" } Set-Clipboard -Value "nvm upgrade -F -mfw $query" -Verbose ediag } } } if($RunOnPeerAsWell) { Write-Host `nCopying mfw on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; get-mfw -mfwVersion $args[0] } -ArgumentList $mfwVersion } } function flash-mfw ($mfwVersion, $RunOnPeerAsWell) { get-mfw $mfwVersion $RunOnPeerAsWell } function get-DUP { $Sourcepath = 'c:\EIT_Drivers\DUP' $TargetPath = '\\10.30.35.254\Windows_EIT_Drivers_E4_AH\dup' $a = Test-Path $Sourcepath If (!$a) { new-item $Sourcepath -ItemType Directory -Verbose } ii $Sourcepath ii $TargetPath } #Function not working function phymacstat ($port) { Write-host $value $path = 'c:\EIT_Drivers\ediag' $a = Test-Path $path If (!$a) { Write-Host "No ediag present. Use get-ediag <branch>" } else { $a = Get-ChildItem -Path 'c:\EIT_Drivers\ediag' -Name if ($a.count -le 1) { $ediagPath = $path + "\" + $a #Write-Host $ediagPath } else { for ($i = 1; $i -le $a.Count; $i++) { Write-Host $i. $a[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $a[$itemNumber - 1] $ediagPath = $path + "\" + $item #.\winediag.exe } if ($port) { <#powershell logic Ediag exit will return ediag main screen output which has no of ports field which we select using Select-String function Now this selected output has blank line below and above which we remove through -replace '\n' So we get - "No.ports:2 No.paths:1 No.ports_per_path:2 Is_100G:No" We select 9th char which is no of ports. When we try to convert char to int, it returns ascii value of that char so we first covert it to string and then to int using -As [int} So finally we get $numberOfPorts as integer #> $numberOfPorts = ([string](((ediag exit) | Select-String -Pattern "No.ports:") -replace '\n')[9]) -As [int] if ([int]$port -gt ($numberOfPorts - 1)) { Write-host "Pease provide correct port number, it starts from 0 and not 1" } $tclFile = $ediagPath + "\temp_tcl.tcl" #deleting existing tcl file if (Test-path $tclFile) { Remove-Item $tclFile } #Spilt multiple command if any #$value2 = $value -split ',' #no need to split as when multiple params are enterred comma seperated without using "" or '' then it is treated as array Add-Content $tclFile "phy mac_stat $port" Add-Content $tclFile "exit" #loop per second while (1) { cd $ediagPath .\winediag.exe -rc $tclFile sleep 2 }#while }#if else { cd $ediagPath .\winediag.exe } }#Ediag else block } function PFCConfig_ { #get linkdump #get mcp trace #Qos } function Get-NvmCfg ($value, $RunOnPeerAsWell) { Write-host $value $path = 'c:\EIT_Drivers\ediag' $a = Test-Path $path If (!$a) { Write-Host "No ediag present. Use get-ediag <branch>" } else { $a = Get-ChildItem -Path 'c:\EIT_Drivers\ediag' -Name if ($a.count -le 1) { $ediagPath = $path + "\" + $a #Write-Host $ediagPath } else { for ($i = 1; $i -le $a.Count; $i++) { Write-Host $i. $a[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $a[$itemNumber - 1] $ediagPath = $path + "\" + $item #.\winediag.exe } if ($value) { <#powershell logic Ediag exit will return ediag main screen output which has no of ports field which we select using Select-String function Now this selected output has blank line below and above which we remove through -replace '\n' So we get - "No.ports:2 No.paths:1 No.ports_per_path:2 Is_100G:No" We select 9th char which is no of ports. When we try to convert char to int, it returns ascii value of that char so we first covert it to string and then to int using -As [int} So finally we get $numberOfPorts as integer #> $numberOfPorts = ([string](((ediag exit) | Select-String -Pattern "No.ports:") -replace '\n')[9]) -As [int] $tclFile = $ediagPath + "\temp_tcl.tcl" #deleting existing tcl file if (Test-path $tclFile) { Remove-Item $tclFile } #Spilt multiple command if any #$value2 = $value -split ',' #no need to split as when multiple params are enterred comma seperated without using "" or '' then it is treated as array for ($i = 1; $i -le $numberOfPorts; $i++) { Add-Content $tclFile "dev $i" foreach ($val in $value) { Add-Content $tclFile "nvm cfg $val-" } } Add-Content $tclFile "exit" cd $ediagPath .\winediag.exe -rc $tclFile } else { cd $ediagPath .\winediag.exe } }#Ediag else block if($RunOnPeerAsWell) { Write-Host `nGetting NVM CFG Value of $value from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Get-NvmCfg -value $args[0] } -ArgumentList $value } } function Set-NvmCfg ($nvmCfgNumber, $value, $RunOnPeerAsWell) { Write-host $value $path = 'c:\EIT_Drivers\ediag' $a = Test-Path $path If (!$a) { Write-Host "No ediag present. Use get-ediag <branch>" } else { $a = Get-ChildItem -Path 'c:\EIT_Drivers\ediag' -Name if ($a.count -le 1) { $ediagPath = $path + "\" + $a #Write-Host $ediagPath } else { for ($i = 1; $i -le $a.Count; $i++) { Write-Host $i. $a[$i - 1] } $itemNumber = Read-Host -Prompt 'Enter Number - ' $item = $a[$itemNumber - 1] $ediagPath = $path + "\" + $item #.\winediag.exe } if ($value -or ($value -eq 0)) { <#powershell logic Ediag exit will return ediag main screen output which has no of ports field which we select using Select-String function Now this selected output has blank line below and above which we remove through -replace '\n' So we get - "No.ports:2 No.paths:1 No.ports_per_path:2 Is_100G:No" We select 9th char which is no of ports. When we try to convert char to int, it returns ascii value of that char so we first covert it to string and then to int using -As [int} So finally we get $numberOfPorts as integer #> $numberOfPorts = ([string](((ediag exit) | Select-String -Pattern "No.ports:") -replace '\n')[9]) -As [int] $tclFile = $ediagPath + "\temp_tcl.tcl" #deleting existing tcl file if (Test-path $tclFile) { Remove-Item $tclFile } #Spilt multiple command if any #$value2 = $value -split ',' #no need to split as when multiple params are enterred comma seperated without using "" or '' then it is treated as array for ($i = 1; $i -le $numberOfPorts; $i++) { Add-Content $tclFile "dev $i" #Reading values before setting it. foreach ($val in $value) { Add-Content $tclFile "nvm cfg $nvmCfgNumber-" } foreach ($val in $value) { Add-Content $tclFile "nvm cfg $nvmCfgNumber=$val" } #Reading the values set above, this need system reboot to reflect foreach ($val in $value) { Add-Content $tclFile "nvm cfg $nvmCfgNumber-" } } Add-Content $tclFile "exit" cd $ediagPath .\winediag.exe -rc $tclFile } else { cd $ediagPath .\winediag.exe } }#Ediag else block if($RunOnPeerAsWell) { Write-Host `nSeting nvm cfg value of $nvmCfgNumber to $value on $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; Set-NvmCfg -nvmCfgNumber $args[0] -value $args[1]} -ArgumentList $nvmCfgNumber, $value } } function ediag ($param) { $path = 'c:\EIT_Drivers\ediag' If (!(Test-Path $path)) { Write-Host "No ediag present. Use get-ediag <branch>" Write-Host "For now copying ediag 8.60.22.0 to c:\EIT_Drivers\ediag" get-ediag 8.60.22.0 } #Selecting very first directory in case of multiple directories $ediagPath = (Get-ChildItem -Path $path -Directory)[0].FullName if ($param) { $tclFile = $ediagPath + "\temp_tcl.tcl" #deleting existing tcl file if (Test-path $tclFile) { Remove-Item $tclFile } #If $param contains nvm cfg for {set i 1} {$i < 7} {incr i} {puts [device $i];puts [nvm cfg 202=3] } #Spilt multiple command if any $param = $param.split(',') Add-Content $tclFile $param Add-Content $tclFile "exit" cd $ediagPath .\winediag.exe -rc $tclFile } else { cd $ediagPath .\winediag.exe } } function set-recordingHandlerOffline ($busNumber, $rhStroms, $PCIBuffer) { $path = 'c:\EIT_Drivers\ediag' If (!(Test-Path $path)) { Write-Host "No ediag present. Use get-ediag <branch>" } else { Dis-VBD #Selecting very first directory in case of multiple directories #This can be modified to select winediag.exe path instread of a directory $ediagPath = (Get-ChildItem -Path $path -Directory)[0].FullName cd $ediagPath Write-Host Command copied in clipboard, just paste in ediag Set-Clipboard -Value "dbgConfig -rh $rhStroms -pci $PCIBuffer" .\winediag.exe -offline $busNumber dbgView En-VBD #Write code to capture dbgView trace and check for the line which says debug bus enabled. } } function grcDump($dumpName, $RunOnPeerAsWell, $remoteExecDONTUSETHIS) { if($RunOnPeerAsWell) { $SutDumpName = $dumpName + "_SUT" $PeerDumpName = $dumpName + "_PEER" Write-Host `n`ngetting grcDump on SUT `n`n -ForegroundColor Yellow ediag -param "grcDump $SutDumpName" Write-Host `n`nCompressing SUT grc to zip `n`n $SUTpath = [string]$(pwd).Path + "\" + $SutDumpName Compress-Archive -Path $SUTpath -DestinationPath "$SutDumpName.zip" Write-Host `n`nGetting grcDump on Peer `n`n -ForegroundColor Yellow Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock { Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; grcDump -dumpName $args[0] -remoteExecDONTUSETHIS 1} -ArgumentList ($PeerDumpName) $PEERpath = (Get-ChildItem \\$(Get-PeerIp)\c$\eit_drivers\ediag\*\ -Include "$PeerDumpName.zip" -Recurse).FullName Write-Host `n`nCopying Peer GRC Zip file to SUT`n`n -ForegroundColor Yellow Copy-Item $PEERpath $(pwd).Path -Verbose pwd | ii } #This is for execution just to have that ii thing, will improve this logic later. if(!($remoteExecDONTUSETHIS) -and !($RunOnPeerAsWell)) { Write-Host getting grcDump $dumpName PEEEEEEEEEEEERRRRRRRR ediag -param "grcDump $dumpName" Write-Host the PWD is $(pwd) $dumppath = [string]$(pwd).path Write-Host DUMPAPTH $dumppath Compress-Archive -Path $dumppath\$dumpName -DestinationPath "$dumpName.zip" -Verbose ii $dumppath -ErrorAction SilentlyContinue } #This is for remote execution just to avoid that ii thing as ii gives error opening remote session, will improve this logic later. if($remoteExecDONTUSETHIS) { ediag -param "grcDump $dumpName" Write-Host the PWD is $(pwd) $dumppath = [string]$(pwd).path Compress-Archive -Path $dumppath\$dumpName -DestinationPath "$dumpName.zip" -Verbose } } function mcptrace($RunOnPeerAsWell) { ediag -param "mcp trace" if($RunOnPeerAsWell) { Write-Host `nGetting mcp trace from $(Get-PeerIp) -ForegroundColor Cyan Invoke-Command -Authentication Negotiate -ComputerName $(Get-PeerIp) -Credential $cred -ScriptBlock {Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1; mcptrace } } } function linkdump () { #function is right but somehow ediag doesnt return the output of this command, tried manually as well but linkdump doesnt work when its fired through -rc option, same goes with phy mac_stat #ediag -param "linkdump" Set-Clipboard "linkdump" -Verbose Write-host "linkdump command copied to clipboard, press ctrl+V and Enter" ediag } function regread_FlowControl_Legacy_PFC() { #function is right but somehow ediag doesnt return the output of this command, tried manually as well but linkdump doesnt work when its fired through -rc option, same goes with phy mac_stat #ediag -param "reg_read -n NIG_REG_FLOWCTRL_MODE" set-Clipboard "reg_read -n NIG_REG_FLOWCTRL_MODE" -Verbose Write-host "reg_read command copied to clipboard, press ctrl+V and Enter" ediag } function regread_DONEnableDisableCheck() { #function is right but somehow ediag doesnt return the output of this command, tried manually as well but linkdump doesnt work when its fired through -rc option, same goes with phy mac_stat #ediag -param "reg_read -n NIG_REG_FLOWCTRL_MODE" Write-Host "To Enable DON - mcp enable_don To Disable DON - mcp disable_don " set-Clipboard "reg_read -n NIG_REG_L2FILT_ETHERTYPE2" -Verbose Write-host "reg_read command copied to clipboard, press ctrl+V and Enter" ediag } ####################################################################ediag END######################################################################## #########################################Profile related commands####################################### #Will not work function Load-Profile { Rename-Item $PSHOME\profile.ps2 $PSHOME\Profile.Ps1 Powershell } function UnLoad-Profile { remove-item $PSHOME\Profile.ps2 -ErrorAction SilentlyContinue -Force Rename-Item "$PSHOME\Profile.ps1" "$PSHOME\Profile.ps2" } #push profile from one system to other function push-Profile ($SystemIP, $ToAllVMs, $FromAVmToAllOtherVms) { $sourcePath = "$PSHOME\Profile.ps1" if($ToAllVMs) { if ($FromAVmToAllOtherVms) { #find the hostname of of the host machine from VM registry settings $HostName = (Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\").GetValue("Hostname") $VMNames = (get-vm -ComputerName $HostName | Where-Object -Property State -eq 'Running').Name } else { $VMNames = (get-vm | Where-Object -Property State -eq 'Running').Name } foreach ($temp in $VMNames) { Write-host Copying to $temp Get-VMIntegrationService $temp | ? { -not($_.Enabled) } | Enable-VMIntegrationService -Verbose Copy-VMFile -Name $temp -SourcePath $sourcePath -Verbose -DestinationPath "c:\" -FileSource Host -Force #This is for 2012R2, Invoke-Command -Authentication Negotiate -ComputerName $ip -ScriptBlock {Move-Item C:\Profile.Ps1 $PSHOME -Verbose} -Credential $cred Invoke-Command -VMName $temp -ScriptBlock {Move-Item C:\Profile.Ps1 $PSHOME -Verbose -Force -Confirm:0} -Credential $cred } }#IfToallVms else { Copy-Item -Path "$PSHOME\Profile.ps1" -Destination \\$SystemIP\C$\Windows\System32\WindowsPowerShell\v1.0 -Passthru -Recurse -Force -Verbose } } function open-Profile { ise $PSHOME\Profile.ps1 } function edit-Profile { open-Profile } #########################################Profile related commands End###################################### #####################################Powershell Startup############################### #Whatever you want to put in powershell startup for host Write-Host Profile is loaded. cd \ if ((Get-WmiObject -Class Win32_computersystem).model -eq "Virtual Machine") { Set-ResolutionInVM 800 600 } #####################################Powershell Startup End############################### #Pxe verification - Shift-f10 driverquery or taskmgr. #Vm Processor % of totol system resource, just something new. #Add this in #bcdedit /set {default} recoveryenabled No #SearchEventLogs <# Example 5: Search for a string in the Application log PowerShell PS C:\> $Events = Get-EventLog -LogName application -Newest 100 PS C:\> $Events | Select-String -InputObject {$_.message} -Pattern "failed" #> #Raritan Function raritan { param( $RackName ) Write-Host $RackName } function DumpLocationPune { ii \\marvell.com\data\Pune\scbu_sw_rel\win_bug_log\eng\sjadhav\ #ii \\qidl-engr01-nas.qidl.na\win_bug_log Set-Clipboard -Value "\\marvell.com\data\Pune\scbu_sw_rel\win_bug_log\eng\sjadhav\" -Verbose Write-host Pune: \\marvell.com\data\Pune\scbu_sw_rel\win_bug_log\eng\sjadhav\ Write-host Pune: \\qidl-engr01-nas.qidl.na\win_bug_log Write-host US: \\dc5prcavcifs01.caveonetworks.com\win_bug_log Write-Host Israel: \\il-engr01-nas.il.marvell.com\win_bug_log } function QidlCDShare { ii \\qlogic.org\qidl_proj\nseg2\CD } function b10kdReleaseLocation { ii \\marvell.com\data\Pune\scbu_sw_rel\Windows\b10kd } function qendaReleaseLocation { ii \\marvell.com\data\Pune\scbu_sw_rel\Windows\qend } function qevbdaReleaseLocation { ii \\marvell.com\data\Pune\scbu_sw_rel\Windows\qevbd } function DumpLocation { ii \\10.30.35.254\i$\Dumps #ii \\10.30.35.26\e$\dumps } function DumpLocationUSVM { #ii \\10.30.35.254\c$\dump ii \\10.104.217.223\c$\dumps } Function version { $PSVersionTable.PSVersion } Function ver { version } #VM Debugger #only this is needed - cmd /c bcdedit /dbgsettings net hostip:172.28.8.195 port:$port key:1.2.3.4 #Try in case of multiple host vnics in VM function set-MSIXMode ($value) { if ((Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters | Select-Object -Property *) -match "ConnectionCountPerRdmaNetworkInterface") { Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -Verbose -Force $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } else { Write-Host "Key is not present in registry. Defining.. " New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -PropertyType Dword -Verbose $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } } function set-LeagacyMode ($value) { if ((Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters | Select-Object -Property *) -match "ConnectionCountPerRdmaNetworkInterface") { Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -Verbose -Force $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } else { Write-Host "Key is not present in registry. Defining.. " New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\ -Name ConnectionCountPerRdmaNetworkInterface -Value $value -PropertyType Dword -Verbose $a = (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters -Name ConnectionCountPerRdmaNetworkInterface).ConnectionCountPerRdmaNetworkInterface Write-Host "ConnectionCountPerRdmaNetworkInterface = $a" } } function rebooter { #Record driver status #Start traffic } #Counter - Per Processor network activity cycles, per proc net interface card activity - dpc/sec #Get-Counter -Counter "\Processor Information(*)\DPCs Queued/sec" #((Get-NetAdapterRss P1).IndirectionTable).ProcessorNumber | Sort-Object | Get-Unique <#Wireshark Capture 4 tshark.exe -i P1 -c 1000 -Y "ip.src == 192.168.11.133 && frame.len > 1514" 5 tshark.exe -i P1 -c 1000 -Y "ip.src == 192.168.11.133 && frame.len > 60000" 6 tshark.exe -i P1 -c 1000 -Y "ip.src == 192.168.11.133 && frame.len > 60000" 7 tshark.exe -i P2 -c 1000 -Y "ip.src == 192.168.12.133 && frame.len > 60000" 8 tshark.exe -i P2 -c 1000 -Y "ip.src == be12::133 && frame.len > 60000" 9 tshark.exe -i P2 -c 1000 -Y "ipv6.src == be12::133 && frame.len > 60000" 10 tshark.exe -i P2 -c 1000 -Y "ipv6.src == ce12::133 && frame.len > 60000" 11 tshark.exe -i P1 -c 1000 -Y "ipv6.src == ce11::133 && frame.len > 60000" #> #Max QP function -> maxQP -remoteip -IPv4 -ipv6 |