VMware Cloud Community
IgnitionUSMC
Contributor
Contributor

PowerCLI script to change <ThreadStackSizeKB> in vpxa.cfg

I want to modify all of my 400+ esxi hosts with modified line in the vpxa.cfg file. I want to change the threadstacksizekb to 256 from 128

<Config>
<vmacore>
<threadPool>
<ThreadStackSizeKb>256</ThreadStackSizeKb>
</threadPool>
</vmacore>
</Config>

I usually use PCLI to do the majority of my tasks and this is no different. Help me PowerCLI community, you are my only hope 😜 /vStarwars

0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership

This is almost the same question as in Editing vpxa.cfg. Take a look at the answers provided there.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
IgnitionUSMC
Contributor
Contributor

Ah, I figured it out... same way I scripted replacing the welcome & motd file.

#edit, cant get the script to display right

0 Kudos
RvdNieuwendijk
Leadership
Leadership

See Some ways to enter PowerCLI code under the new forum SW to learn some ways to insert PowerCLI code in posts in this community.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
IgnitionUSMC
Contributor
Contributor

#VPXA.cfg mod

#Import NetApp Powershell CMDLETS
Import-Module DataonTap

#Capture all ESXi hosts
$VMHosts = Get-VMHost

#Capture Date/Time of Execution
$FileDate = get-date -format yyyyMMdd"_"HHmm

#Capture ESXi host creds
Write-Host please enter ESXi credentials
$Creds = Get-Credential

#Options
$readVPXA = $true

Foreach($vmh in $VMHosts){
    $startSSH = $false
    Write-Host "Modifying ESXi Host:"$vmh.Name
    #Start the SSH Service
    if($VMH | Get-VMHostService | Where { $_.Key -match "TSM" -and $_.Running -ne "true"}){
        $VMH | Get-VMHostService | Where { $_.Key -match "TSM"} | Start-VMHostService -Confirm:$false | Out-Null
        $startSSH = $true
    }
    
    #Store old files with time/date
    Write-Host "Backing up config file"
    invoke-nassh -name $VMH.Name -Credential $Creds "cp -p /etc/vmware/vpxa/vpxa.cfg /etc/vmware/vpxa/vpxa.cfg.old_$FileDate" | Out-Null
    
    #Modifying the vpxa.cfg
    Write-Host "Modifying VPXA.CFG with modified ThreadStackSizeKB"
    Invoke-NaSsh -Name $VMH.Name -Credential $Creds    "sed -i -e's/<ThreadStackSizeKb>128</<ThreadStackSizeKb>256</' /etc/vmware/vpxa/vpxa.cfg" | Out-Null
    if($readVPXA){
        Write-Host "Here is the modified line on the vpxa.cfg"
        Invoke-NaSsh -Name $VMH.Name -Credential $Creds "cat /etc/vmware/vpxa/vpxa.cfg | grep -i ThreadStackSize" 
    }
    Write-Host ""
    
    #Stop the SSH Service if it was started by this script
    if($startSSH){
        $VMH | Get-VMHostService | Where { $_.Key -match "TSM"} | Stop-VMHostService -Confirm:$false | Out-Null
        $startSSH = $false
    }
}



0 Kudos
IgnitionUSMC
Contributor
Contributor

FINALLY!... lol thanks for that post

0 Kudos