VMware Cloud Community
vmdavinci
Contributor
Contributor
Jump to solution

Install HP Management Agents with VI Toolki

Is it possible to install HP Management Agents with VI Toolkit?

If it is yes here's my plan:

Get all ESX Servers in Cluster/Datacenter

Get HP Management Agent Version

If HP Management agent version < x then upgrade

Start upgrade

Download HP Management agent installer from FTP/NFS

Deinstall HP Management agent

Install new HP Management agent

I need some help to start.

Reply
0 Kudos
1 Solution

Accepted Solutions
RobMokkink
Expert
Expert
Jump to solution

Here is an sample:



$ErrorActionPreference = "Continue"


$PLINK = ".\plink.exe -l"


#GET USERNAME AND PASSWORD
$USER = Read-Host "Enter Username"
$PASSWD = Read-Host "Enter Password" -AsSecureString
$ESXHOST = Read-Host "Enter ESX HOST FQDN"
$SYSLOGSRV = Read-Host "Enter SyslogServer"



#CONVERT SECURESTRING
$CONVERT_PASSWORD = [http://System.Runtime.InteropServices.Marshal|http://System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PASSWD)
$PASSWORD = [http://System.Runtime.InteropServices.Marshal|http://System.Runtime.InteropServices.Marshal]::PtrToStringAuto($CONVERT_PASSWORD)



#SYSLOG ENTRY
$SYSLOGSTRING = [char]39 +  "`n" + "#NWORKS SYSLOG SERVER" +  "`n" + "*.*" + "`t`t`t`t`t" + '@' + $SYSLOGSRV + [char]39



$STRCMD1 = "echo Y | " + $PLINK + " " + $USER + " " + "-pw" + " " + $PASSWORD + " " + $ESXHOST + " exit"
$STRCMD2 = $PLINK + " " + $USER + " " + "-pw" + " " + $PASSWORD + " " + $ESXHOST + " " + "sudo /sbin/service ntpd restart"
write-output "Updating syslog for host: $ESXHOST"
invoke-expression $STRCMD1
invoke-expression $STRCMD2


 

I don't have a linux management box, because the operations team does not understand the console.

View solution in original post

Reply
0 Kudos
7 Replies
RobMokkink
Expert
Expert
Jump to solution

You can use plink in combination with powershell to do that.

I have sudo configured properly, so i can use a local account on the esx server or my AD admin account to login to the esx server.

Make a script that logs into your virtualcenter server, get all esx servers, put them in an array en loop through the array.

CITITECHS
Contributor
Contributor
Jump to solution

I also did an agent install using SUDO like Rob . What I did was use Powershell to generate a hostlist that I wanted the Agents on.

Since I have SSH Keys on each host I justed looped thru my list using a bash script. I then scp agents over ,untar them , stopped the old ones from running then uninstall the old agents and reinstall the new agents.

I really cant see you doing it all of it with powershell. Like Rob suggested you could write a powershell script that calls PLINK in PLINK you would have a file that you call that has the commands . I know our storage team uses plink to manage switches. So it does work I personally dont use it.

Reply
0 Kudos
vmdavinci
Contributor
Contributor
Jump to solution

Today I created the bash shell script that update the HP Management Agents. I've already ran it with plink in our testlab.

The next step is building the Powershell script which run Plink. Can you give me a sample of the plink command that start the shell script.

I start the script within plink with the following command:

sudo su -l USERACCOUNT -s /tmp/./examplescript.sh

Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

Here is an sample:



$ErrorActionPreference = "Continue"


$PLINK = ".\plink.exe -l"


#GET USERNAME AND PASSWORD
$USER = Read-Host "Enter Username"
$PASSWD = Read-Host "Enter Password" -AsSecureString
$ESXHOST = Read-Host "Enter ESX HOST FQDN"
$SYSLOGSRV = Read-Host "Enter SyslogServer"



#CONVERT SECURESTRING
$CONVERT_PASSWORD = [http://System.Runtime.InteropServices.Marshal|http://System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PASSWD)
$PASSWORD = [http://System.Runtime.InteropServices.Marshal|http://System.Runtime.InteropServices.Marshal]::PtrToStringAuto($CONVERT_PASSWORD)



#SYSLOG ENTRY
$SYSLOGSTRING = [char]39 +  "`n" + "#NWORKS SYSLOG SERVER" +  "`n" + "*.*" + "`t`t`t`t`t" + '@' + $SYSLOGSRV + [char]39



$STRCMD1 = "echo Y | " + $PLINK + " " + $USER + " " + "-pw" + " " + $PASSWORD + " " + $ESXHOST + " exit"
$STRCMD2 = $PLINK + " " + $USER + " " + "-pw" + " " + $PASSWORD + " " + $ESXHOST + " " + "sudo /sbin/service ntpd restart"
write-output "Updating syslog for host: $ESXHOST"
invoke-expression $STRCMD1
invoke-expression $STRCMD2


 

I don't have a linux management box, because the operations team does not understand the console.

Reply
0 Kudos
CITITECHS
Contributor
Contributor
Jump to solution

./plink -ssh -pw mypassword cititechs@server01 -m c:\commands.txt

Reply
0 Kudos
vmdavinci
Contributor
Contributor
Jump to solution

Hi Rob,

Your answer/sample is great! At this moment I run the HP Management Agent Update with Powershell!

Now i need to create a loop in the script so the update will run on all ESX servers.

Reply
0 Kudos
RobMokkink
Expert
Expert
Jump to solution

Here is a snippet:



#GET ALL ESX SERVERS THAT ARE CONNECTED OR IN MAINTENANCE MODE
$ALL_ESXHOSTS = get-vmhost | sort | where { $_.State -eq "Connected" -or $_.State -eq "Maintenance"}


#LOOP THROUGH THE ARRAY
foreach ($i in $ALL_ESXHOSTS)
  { 
     $ESXHOST = $i.name
     Get-VMhost $ESXHOST


     #DO SOMETHING BELOW THIS CODE


}


 


Reply
0 Kudos