Powershell Studio help?

This topic contains 5 replies, has 2 voices, and was last updated by  Paul DeArment Jr 3 months, 3 weeks ago.

  • Author
    Posts
  • #77749

    cm
    Participant

    Right now I am learning Powershell Studio, so I have a basic code that has a Button plus a RichTextBox.

    Code

    I am having trouble figuring out where I would need to insert my RichTextBox code so I can have the output display there.

    Thanks for any help.

  • #77767

    Paul DeArment Jr
    Participant

    If you want the information to display in the rich text box as soon as you click on the button then the code to display the information in the text box should appear in the event for the button click for the button SystemInfo – $buttonSystemInfo_Click

    • #77772

      cm
      Participant

      I did have $RichTextBox.Text = $Object. Runs but nothing is displayed.

    • #77776

      Paul DeArment Jr
      Participant

      I tried the following chunk and it worked fine and showed up in my copy of studio

      
      $buttonSystemInfo_Click = {
      	#TODO: Place custom script here
      	Import-Module Activedirectory
      	$pc = Read-Host -Prompt " Enter Computer Name"
      	$bios = Get-WmiObject Win32_BIOS -ComputerName $pc
      	$networkResult = Get-WmiObject win32_networkadapterconfiguration -Filter 'ipenabled = "true"' -ComputerName $pc
      	
      	$Object = New-Object PSObject -Property @{
      		'BIOS Version'	     = $bios.Version
      		'Serial Number'	     = $bios.SerialNumber
      		'MACAddress'		 = $networkResult.MACAddress
      	}
      	$richtextbox1.text = $Object | Out-String
      }
      

      The formatting isn't the nicest doing just out-string like that so i cleaned it up a little

      $richtextbox1.Text = $object.psobject.properties | Where-Object{ $_.membertype -eq "noteproperty" } | ForEach-Object{
      		"$($_.name) - $($_.value)`r`n"
      	}
      
  • #77779

    cm
    Participant

    Hey I appreciate the help. I was putting the code in the wrong line. It works, now I have to work on formatting it. Would format-table be better?

    • #77788

      Paul DeArment Jr
      Participant

      Not on my computer with studio but I imagine it would not be better off the top of my head. You can always test it out to see if its better as well

You must be logged in to reply to this topic.