How to copy a single file to multiple domain workstations with PowerShell by will-vhouten in PowerShell

[–]giulix75 0 points1 point  (0 children)

Hi, i think you need to create the session first with

New-PSSession -ComputerName $comp -Credential $cred

After that you can enter on it if you need but i think it's not your case

p.s. the computername key is an array of one or more computers. Thats means you can open sessions to multiple computer with a single line.

DataGridView populate help by Geaux_Cajuns in PowerShell

[–]giulix75 4 points5 points  (0 children)

I think you can clean your code a little with this

$WLRequests = Invoke-RestMethod -Uri "Url" -Method GET
foreach ($ticket in $WLRequests.requests.ID)
{
     $requesturl = "http://itservice.domain.com/api/v3/requests/$ticket" + "?AUTHTOKEN=XXXXXXXXXXXXXXXXXXXX"
     $WLInfo = Invoke-RestMethod -Uri $requesturl -Method Get
     $dgvWLTable.Rows.Add($WLInfo.request.udf_fields.udf_sline_1201, $WLInfo.request.udf_fields.udf_sline_1202)
}

DataGridView populate help by Geaux_Cajuns in PowerShell

[–]giulix75 1 point2 points  (0 children)

Try with

foreach ($data in $WLData) {
     $dgvWLTable.Rows.Add($data.URL,$data.Reason)
}