1 2 3 4 Previous Next 46 Replies Latest reply on Feb 20, 2020 10:55 AM by jvm2016

    cannot bind parameter_powercli

    jvm2016 Expert

      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 ???

       

        • 1. Re: cannot bind parameter_powercli
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          The New-ContentLibrary cmdlet doesn't seem to support OBN for the Datastore parameter.
          You will have to do a Get-Datastore to pass the parameter.

           

          New-ContentLibrary -Name Test -Datastore (Get-Datastore -Name TestDS)

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: cannot bind parameter_powercli
            jvm2016 Expert

            it was working fine yesterday .today its not

            • 3. Re: cannot bind parameter_powercli
              LucD Guru
              Community WarriorsvExpertUser Moderators

              Did you change PowerCLI versions in between?

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: cannot bind parameter_powercli
                jvm2016 Expert

                well content library commands are available from 11.5 version onwards and thats why i updated powercli .

                however if you see below example it is actually taking value from variable

                 

                • 5. Re: cannot bind parameter_powercli
                  LucD Guru
                  vExpertCommunity WarriorsUser Moderators

                  Correct, but that variable most probably contains a Datastore object, not a String.

                  I repeat, it looks as if the PowerCLI Dev Team didn't use OBN on the Datastore parameter of the cmdlet

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 6. Re: cannot bind parameter_powercli
                    jvm2016 Expert

                    i am going to check this again .

                    • 7. Re: cannot bind parameter_powercli
                      Zsoldier Expert
                      vExpert

                      I notice your screenshot example is calling a `create-contentlibrary` rather than the official cmdlet `New-ContentLibrary`.  Are you using a custom module/function?  That would probably explain the difference in behavior.

                      • 8. Re: cannot bind parameter_powercli
                        LucD Guru
                        vExpertUser ModeratorsCommunity Warriors

                        The user is creating a module.
                        The Create-ContentLibrary is his function, in there he calls New-ContentLibrary.

                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 9. Re: cannot bind parameter_powercli
                          jvm2016 Expert

                          new-contentlibrary is a strightforward powercli comand .

                          however in this thread we are using that command under function  create-contentlibray which has included concept of

                          checking service using posh-ssh module and at the same time publishing to secondary site if any .

                          • 10. Re: cannot bind parameter_powercli
                            jvm2016 Expert

                            i see a different weired issue the comand new-contentlibrary is avaliable but i cant use inside function.

                             

                             

                            • 11. Re: cannot bind parameter_powercli
                              LucD Guru
                              User ModeratorsCommunity WarriorsvExpert

                              I would need to see the code to analyse.
                              I suspect that there might be a quote issue somewhere

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 12. Re: cannot bind parameter_powercli
                                jvm2016 Expert

                                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

                                 

                                 

                                #checking content lib service using posh-ssh

                                #$cred_root=Get-Credential

                                $session_vcsa=New-SSHSession -ComputerName vcsa-01a.corp.local -Credential $cred_root

                                $session_vcsa_id=$session_vcsa.SessionId

                                 

                                $conlib=Invoke-SSHCommand -Command "service-control --status vmware-content-library" -SessionId $session_vcsa_id

                                if ($conlib.output -icontains "running:")

                                 

                                 

                                {

                                 

                                 

                                write-host "service of content lib is running "

                                write-host "creating content lib" -ForegroundColor Cyan

                                 

                                 

                                #Connect-VIServer -server vcsa-01a.corp.local -Credential $Credential_vcenter

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

                                 

                                #publishing to secondary site

                                 

                                #$conlib.PublishUrl

                                #New-ContentLibrary -Name "subscribed to siteB" -SubscriptionUrl $conlib.PublishUrl -Description "subscribed to site B" -datastore (get-datastore) -AutomaticSync

                                 

                                 

                                }

                                 

                                else

                                {

                                 

                                write-host "content lib service needs to be restarted " -ForegroundColor Blue

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

                                Connect-VIServer -server vcsa-01a.corp.local -Credential $cred_administrator

                                write-host "creating content lib" -ForegroundColor Cyan

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

                                 

                                 

                                 

                                 

                                 

                                }

                                 

                                }

                                 

                                 

                                 

                                above is what i am trying .it assumes that posh-ssh is already installed.

                                • 13. Re: cannot bind parameter_powercli
                                  LucD Guru
                                  Community WarriorsvExpertUser Moderators

                                  That code doesn't have a problem as far as I can see.

                                  But then this is probably not the code you ran since the line number in the error doesn't correspond.

                                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                  • 14. Re: cannot bind parameter_powercli
                                    LucD Guru
                                    vExpertUser ModeratorsCommunity Warriors

                                    As a debugging aid, you could insert a Get-Module just before the cmdlet

                                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                    1 2 3 4 Previous Next