Page 1 of 1

How to foreach from datagridview

Posted: Fri Sep 11, 2020 7:01 am
by smith523
I try to create a loop Like Excel
$csv = Import-Excel “C:\Script\tes.xlsx”
$Count=0
foreach ($item in $csv){
” $($item.example) $($item.example) “



$datagridview1.Rows | Select-Object -ExpandProperty DataBoundItem | Export-Csv $home\AppData\Local\Temp\test.csv -NoTypeInformation -Encoding UTF8 -Force
$csv = Import-Csv -Path $home\AppData\Local\Temp\Test.csv
$Count = 0
foreach ($item in $csv)
{
Start-Process -FilePath SSh.exe -ArgumentList "$($item.ipaddress)"
$Divacename = Echo 'test "$($item.Divacename)"
$provisioning = Echo 'test' "$($item.provisioning)"


Or

foreach ($item in $datagridview1)
{
Start-Process -FilePath SSh.exe -ArgumentList "$($item.ipaddress)"
$Divacename = Echo 'Test' "$($item.Divacename)"
$provisioning = Echo 'Test2' "$($item.provisioning)"