VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

cannot bind parameter_powercli

hi luc ,

if yu could suggest how to fix this error  .this is one of the functions wherein it will create the content lib based on datasore provided .

[string]$datastore is one of the parameters   .do i need to change the string to something else ???

pastedImage_0.png

46 Replies
jvm2016
Hot Shot
Hot Shot
Jump to solution

all i am able to conclude is that get-contentlibrary comand which seems available from 11.5 vmware.vimautomation.core module is not working or not avaiable .

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is this still in the HoL environment?

Which Lab?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

pastedImage_0.png

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Works for me

cl.jpg

But you have stop/start your PowerShell session after the Update-Module to 11.5

If I don't do that, I also get the same error.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

i have been exposed to all sort of errors

if yu could please check only this portion

function create-contentlib {

    [cmdletbinding()]

    param (

        [parameter(mandatory = $true,

            valuefrompipeline = $true,

            valuefrompipelinebypropertyname = $true)]

        [string]$viserver,

        [parameter(mandatory = $true)]

        [PSCredential]$Credential_vcenter,

        [parameter(mandatory = $true)]

        [PSCredential]$Credential_root,

        [parameter(mandatory = $true)]

        [string]$datastore

    )

    Connect-VIServer -server $viserver -Credential $Credential_vcenter | Out-Null

    $session = New-SSHSession -ComputerName $viserver -Credential $Credential_root

    $stream = New-SSHShellStream -SSHSession $session -TerminalName xterm

    # Open shell

    Invoke-SSHStreamShellCommand -ShellStream $stream -PrompPattern "Shell access is granted" -Command 'shell' | Out-Null

    # Run command

    $result = Invoke-SSHStreamShellCommand -ShellStream $stream -PrompPattern "]#" -Command 'service-control --status vmware-content-library'

    if (($result -join '') -notmatch 'Running:') {

        Write-Host "content lib service needs to be restarted " -ForegroundColor Blue

        Invoke-SSHCommand -Command "service-control --start vmware-content-library" -SessionId $session_vcsa_id

    }

    Write-Host "creating content lib" -ForegroundColor Cyan

    $conlib = New-ContentLibrary -Name "siteA con lib" -Datastore (Get-Datastore -Name $datastore) -Published -Description "content lib for site A vcenter"

  

    $stream.Close()

    Remove-SSHSession -SSHSession $session | Out-Null

}

with following

administrator@regiona.local

VMware1! 

root

VMware1!

datastore

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you haven't changed my earlier code, that works for me.

Can you just show me the errors?

Looking at code without knowing what to look for is a waste of time.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

finally it is workng .it has motivated me to do more functions and trouble you more Smiley Happy

however i dont know why there was issuse last time related to invoke-sshcoomand as for some reasons it was not able to ssh to vcsa...

pastedImage_0.png

0 Kudos