4 Replies Latest reply on Nov 11, 2019 9:06 PM by ganapa2000

    Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.

    ganapa2000 Hot Shot

      Hi,

       

      I am trying to validate the esxi passwords and trying as below.

       

      connect-viserver 10.10.10.10

      Get-VMHost | select @{n='ESX_Host';e={$_.Name}} | sort ESX_Host | Export-Excel -Path ".\ESX_Host_List.xlsx" -WorkSheetname Host_List

      disconnect-viserver -server * -force -confirm:$false

       

      $user = "root"

      $pswd = "password"

      Import-Excel -Path ".\ESX_Host_List.xlsx" -PipelineVariable row |

      ForEach-Object -Process {

         try

         {

         Connect-VIServer -Server $row.ESX_Host -User $user -Password $pswd -ErrorAction Stop | Out-Null

         Disconnect-VIServer -Server $row.ESX_Host -Confirm:$false

         $result = 'Password_Validation_Success'

         }

         catch

         {

         $result = 'Password_Validation_Failed'

         }

         $row | Add-Member -MemberType NoteProperty -Name 'Password_Validation' -Value $result -PassThru

      } | Export-Excel -Path ".\ESX_Host_Pass_Validation_Result.xlsx" -WorkSheetname Host_Password_Validation

       

       

      I am getting the below error

       

      Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.

      At D:\Root_Password_Validation\2_validate_root_password.ps1:19 char:11

      +    $row | Add-Member -MemberType NoteProperty -Name 'Password_Validat ...

      +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException

          + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCo

         mmand

       

      Please help!!!