Hot Shot
Hot Shot

Script for ssh service start then followed by other commands

Jump to solution

Hi All,

I was trying to merge esxi SSH service start then following by other command in same script but unable to merge the same. Can someone good at powercli help me in creating such script.

The following activities should be done in script.

-> Start SSH service for esxi host (Specific Cluster in vCenter)

Then

-> esxcli sched swap system set -l false

then

-> esxcli system corefump file remove -F

Then stop the SSH service

the above 4 steps should be included in one script.

Thanks in Advance.

 

 

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

Using the PowerCLI Get-EsxCli cmdlet, you don't have to start and stop the SSH service. The following PowerCLI script is the equivalent of your code and runs on all of your hosts. The specify a specific cluster, you have to replace the * with the cluster name:

Get-Cluster -Name * | Get-VMHost | ForEach-Object {

  $esxcli = Get-EsxCli -VMHost $_

  $esxcli.sched.swap.system.set($null,$null,$null,$null,$null,$false,$null)

  $esxcli.system.coredump.file.remove($null,$true)

}

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

View solution in original post

0 Kudos
2 Replies
Leadership
Leadership

Using the PowerCLI Get-EsxCli cmdlet, you don't have to start and stop the SSH service. The following PowerCLI script is the equivalent of your code and runs on all of your hosts. The specify a specific cluster, you have to replace the * with the cluster name:

Get-Cluster -Name * | Get-VMHost | ForEach-Object {

  $esxcli = Get-EsxCli -VMHost $_

  $esxcli.sched.swap.system.set($null,$null,$null,$null,$null,$false,$null)

  $esxcli.system.coredump.file.remove($null,$true)

}

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

View solution in original post

0 Kudos
Hot Shot
Hot Shot

Thanks Mate,

Its working fine. however I made few changes based on my infra. Thanks Smiley Happy

Raju Gunnal VCP 4, VCP 5, VTSP 4, VTSP 5, ITIL V3 http://www.techtosolution.com
0 Kudos