locked
Powershell Output in output text box not coming properly RRS feed

  • Question

  • Hi Team,

    I have created Powershell GUI tool and it is working as excepted but Powershell Output in output text box not coming properly

    example

    when i tried to get the service the output  coming like  below.The state is not in line by line below is the out put

    #####################################################

    $outputBox= New-Object system.windows.Forms.TextBox
    $outputBox.Multiline = $true
    $outputBox.Width = 800
    $outputBox.Height = 222
    $outputBox.ReadOnly =$true
    $outputBox.ScrollBars ="Vertical"
    $outputBox.WordWrap =$false
    $outputBox.location = new-object system.drawing.point(9,350)
    $outputBox.Font = "Lucida Sans ,9"
    
    #################################################
    
    function Service{
    progressbar
    
    $outputBox.Clear()
    $outputBox.Text = "Getting Service status please wait"
    $computers=$InputBox.lines.Split("`n")
    $sname =$filterbox.text
    $date =Get-Date
     $ct = "Task Completed @ " + $date
      $Script:formt.Visible=$true
    foreach ($computer in $computers)
    {
    $Script:formt.text="Working on $computer"
    #$s= Get-Service -ComputerName $computer -Name $sname|  Select-Object MachineName,Name,Status | ft -AutoSize | Out-String
    $s=Get-WmiObject -Class win32_service  -ComputerName $computer   -Filter "Name Like '%$sname%'" |  Select-Object PSComputerName,Name,State | ft -AutoSize | Out-String
    
    $outputBox.Appendtext("{0}`n" -f $s+"`n $ct")
    $Script:formt.close() 
    
    }
    } 
    
    ###########################################
    can some one please help how to figure out this

    

    Friday, December 15, 2017 4:30 AM

Answers

  • All members of the "Lucida" family are non-proportional (fixed).  "Lucida Console" is the most common and is always available on all Windows systems.  "Typewriter" is a bit fancier but may not always be available.  It also has less kerning and leading.


    \_(ツ)_/

    Friday, December 15, 2017 6:55 AM

All replies

  • You have to use a fixed font to maintain spacing.


    \_(ツ)_/

    Friday, December 15, 2017 5:04 AM
  • my issue got resolved after using font style "Lucida Sans Typewriter"..

    tried  fixed font but worked as excepted..Thanks JRV 

    Friday, December 15, 2017 6:49 AM
  • All members of the "Lucida" family are non-proportional (fixed).  "Lucida Console" is the most common and is always available on all Windows systems.  "Typewriter" is a bit fancier but may not always be available.  It also has less kerning and leading.


    \_(ツ)_/

    Friday, December 15, 2017 6:55 AM
  • Ok got Sir..Thanks for the reply..
    Friday, December 15, 2017 6:58 AM