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.
This topic is 3 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
smith523
Posts: 1
Last visit: Wed Oct 26, 2022 11:20 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 12803 times
This topic is 3 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked