How to foreach from datagridview

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
smith523
Posts: 1
Joined: Thu Apr 04, 2019 12:49 am

How to foreach from datagridview

Post 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)"
Attachments
My Column.jpg
My Column.jpg (88.74 KiB) Viewed 1688 times

Locked