I am trying to take the data out of a grid to use the information for other parts of my project. But i keep getting an erorr. I set my winform to mutilselect and SelectionMode to FullRowSelect. Do i have to call it in the script? Please see my script below and the output which is really werid. I selected three different rows and it gives me the same data but also an error.
- $installDatagridview2.SelectedRows | ForEach-Object{
- $results += [pscustomobject]@{
- Username = $installDatagridview2.Rows[$_.Index].Cells[0].Value
- Computername = $installDatagridview2.Rows[$_.Index].Cells[1].Value
- City = $installDatagridview2.Rows[$_.Index].Cells[2].Value
- IPAddress = $installDatagridview2.Rows[$_.Index].Cells[3].Value
- }
- $a = $results | Select-Object Username, Computername, IPAddress
- Write-Host $a
- }
@{Username=user1; Computername=Comp1; IPAddress=10.0.0.0} ERROR: Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'. TDInstaller2.01.psf (327, 4): ERROR: At Line: 327 char: 4 ERROR: + $results += [pscustomobject]@{ ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ERROR: + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException ERROR: + FullyQualifiedErrorId : MethodNotFound ERROR: @{Username=user1; Computername=Comp1; IPAddress=10.0.0.0} ERROR: Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'. TDInstaller2.01.psf (327, 4): ERROR: At Line: 327 char: 4 ERROR: + $results += [pscustomobject]@{ ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ERROR: + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException ERROR: + FullyQualifiedErrorId : MethodNotFound ERROR: @{Username=user1; Computername=Comp1; IPAddress=10.0.0.0}