Automation

 View Only
  • 1.  Automate Reset of LCM (VUM) DB

    Broadcom Employee
    Posted Jun 21, 2022 02:12 PM

    Greetings...

    I'm trying to automate the reset of the LCM (VUM DB) based on VMW KB Resetting VMware Update Manager Database on a vCenter Server Appliance 6.5/6.7/7.0 (2147284). I'm using the POSH-SSH module, and this script logic worked (AFAIK up to VCSA 7.0.3U3c). 

    Just wondering if anyone has any insight on why this stopped working, or a better way to automate this task.

    #script

    /////////////////////////////////////////////////////////////////////

    $PSMODULE_SOURCE = "C:\Source\Scripts\Powershell\Modules"
    $PSMODULE = "Posh-SSH.zip"
    $SSO_Admin = "Administrator@vsphere.local" # put ssoadmin in a variable
    $VCSA_IP = Read-Host -Prompt "Provide IP Address for VCSA" #Get/store target
    $SSO_pw = Read-Host -Prompt "Provide $SSO_Admin password" -AsSecureString #Get/store creds
    $SSO_cred = New-Object System.Management.Automation.PSCredential ($SSO_Admin, $SSO_pw)
    # First uninstall the posh-ssh module
    Get-Module Posh-SSH -ListAvailable | Uninstall-Module -Force -Confirm:$false
    Write-Host "Completed uninstalling older PS Module" -ForegroundColor Green

    #Installs new Posh-SSH Module by Expanding Archive into Auto-load Directory
    Expand-Archive -Path "$PSMODULE_SOURCE\$PSMODULE" -DestinationPath "C:\Program Files\WindowsPowerShell\Modules\" -Force
    Import-Module -Name Posh-SSH
    Write-Host "Completed importing PS Module $PSModule" -ForegroundColor Green

    $sSession = @{
    ComputerName = $VCSA_IP
    Credential = $SSO_cred
    AcceptKey = $true
    }

    $session = New-SSHSession @sSession

    //////////////////////////////////////////////////////////////////////

    I am using Posh-SSH version 3.0.4

    At this point, earlier versions would connect to ssh-session with vcsa, and then using Invoke-SSHCommand run the shell commands to reset the vum db. Now (7.0.3U3e) throws an error:

    New-SSHSession : Exception has been thrown by the target of an invocation.
    At line:9 char:12
    + $session = New-SSHSession @sSession
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (Renci.SshNet.SshClient:SshClient) [New-SSHSession], TargetInvocationException
    + FullyQualifiedErrorId : SSH.NewSshSession



  • 2.  RE: Automate Reset of LCM (VUM) DB

    Posted Jun 21, 2022 04:09 PM

    Works for me with VCSA 7.0.3

    Since you seem to be installing PoshSSH from a ZIP file, did you unblock the ZIP file (Unblock-File cmdlet)?



  • 3.  RE: Automate Reset of LCM (VUM) DB

    Broadcom Employee
    Posted Jun 21, 2022 11:50 PM

    I did. I even connected, and used install-module (uninstalled module first ... the install-module updated nuget provider as well). We normally support closed networks, which is why I install to auto-load location for system. Install the module and then save-module, air gap it to enclave, and work from there.

     

    Reckon its time to rebuild the powershell/cli environment on the enclave jump box ...

    What version of posh-ssh are you using, if you don't mind me asking?



  • 4.  RE: Automate Reset of LCM (VUM) DB

    Posted Jun 22, 2022 06:15 AM

    The latest, currently 3.0.4