Powershell Studio help?

Welcome Forums General PowerShell Q&A Powershell Studio help?

This topic contains 5 replies, has 2 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #77749
    cm

    Participant
    Points: 2
    Rank: Member

    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

    Participant
    Points: 28
    Rank: Member

    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
      Points: 2
      Rank: Member

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

    • #77776

      Participant
      Points: 28
      Rank: Member

      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
    Points: 2
    Rank: Member

    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

      Participant
      Points: 28
      Rank: Member

      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

The topic ‘Powershell Studio help?’ is closed to new replies.