vSphere: no coredump target has been configured (fix it w/ powershell)

Was able to fix the above error by following steps outlined here:

So that inspired me to write how you can do this against multiple hosts via a scripted method.  I started by simply exporting a list of servers via PowerCLI:
Get-Cluster myCluster | get-vmhost | select name | out-file -FilePath D:\scripts\Output\clusterlist.txt -Encoding ascii

I opened the txt file, removed the 'name' header, then ran the following:

for server in $(cat ~/Desktop/clusterlist.txt);

do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$server 'esxcli system coredump partition set -u; esxcli system coredump partition set --enable true --smart'


A better way to do this would be to use plink, above was a quick and dirty way for me.  So here is a way to do it all from Powershell only that quite frankly would've saved me the trouble of pasting the password in 20 times:

$Creds = get-credential
#Echo "n" because I don't want or care for putty/plink to record the server ssh/rsa key.
$ClusterHosts = Get-Cluster myCluster | get-vmhost
Foreach ($ClusterHost in $ClusterHosts)
$ClusterHost| Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} | Start-VMHostService
echo n | C:\someplace\plink.exe $ClusterHost.Name -l $creds.username -pw $creds.GetNetworkCredential().password "esxcli system coredump partition set -u; esxcli system coredump partition set --enabled true --smart"

$ClusterHost| Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} | Stop-VMHostService -confirm:$false

Alan wrote a little snippet awhile back where you can insert it so that it'll download plink automatically for you.  It's also how I remember the little echo trick.

[Update: Just realized that this needs SSH service turned on and that I really didn't include loop statement.  Snippets inserted above]

Even better way:
$ClusterHosts = Get-Cluster myCluster | get-vmhost | get-esxcli
Foreach ($ClusterHost in $ClusterHosts)

No comments: