datagridwiew result

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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 10 months and 6 days 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
olivier56
Posts: 16
Last visit: Tue Jan 09, 2024 6:58 am

datagridwiew result

Post by olivier56 »

hi

I can't get the result of my script in the datagridview.
I would like it to display the displayname value in the datagridview
THANKS



$rules=Get-NetFirewallRule
$DisplayGroups=foreach ($rule in $rules){$rule.displaygroup}
$DisplayGroups | Select-Object -Unique
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: datagridwiew result

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Domtar
Posts: 133
Last visit: Mon Mar 11, 2024 5:38 am
Has voted: 2 times

Re: datagridwiew result

Post by Domtar »

you do not have any datagrid in your code, try this

$DisplayGroups | out-gridview
olivier56
Posts: 16
Last visit: Tue Jan 09, 2024 6:58 am

Re: datagridwiew result

Post by olivier56 »

hi

thank you but don t work

my code
$rules = Get-NetFirewallRule
$DisplayGroups = foreach ($rule in $rules) { $rule.displaygroup }
$DisplayGroups | Select-Object -Unique

Update-DataGridView -DataGridView $datagridview1 -Item $DisplayGroups

Update-DataGridView: Failed to validate argument on parameter 'Item'. Argument is null or an element of argument collection
ERROR: contains a null value. Specify a collection that does not contain a null value and try again.
ERROR: At character C:\Users\orabache\Videos\SAPIEN\PowerShell Studio\Files\firewall\firewall.Run.ps1:346: 58

when i debug the value n is empty pad
olivier56
Posts: 16
Last visit: Tue Jan 09, 2024 6:58 am

Re: datagridwiew result

Post by olivier56 »

I changed the code variable
and it only shows me the length of the result string
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: datagridwiew result

Post by jvierra »

The issue is tat you are not working with "Object" or "PsObject" collections:. Tiese objects are "CIM" objects,

See:
TypeName: Selected.Microsoft.Management.Infrastructure.CimInstance
  1.    
  2.  
  3. Name        MemberType   Definition
  4. ----        ----------   ----------
  5. Equals      Method       bool Equals(System.Object obj)
  6. GetHashCode Method       int GetHashCode()
  7. GetType     Method       type GetType()
  8. ToString    Method       string ToString()
  9. DisplayName NoteProperty System.String DisplayName=Wi-Fi Direct Spooler Use (Out)
  10. Name        NoteProperty string Name=WFDPRINT-SPOOL-Out-Active
This topic is 10 months and 6 days 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