<# This uses PowerShell remoting to run sysinfo and displays results in a windows forms text box A. Kaplan www.akaplan.com 4/6/21 #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [String] $ComputerName ) function Out-TextBox { [CmdletBinding()] Param ( # StrText help description [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] $objIn, # Title help description [Parameter(Mandatory = $False, Position = 1)] [string]$Title = "Results" ) begin { $txt = @() } process { $txt += $objIn } End { #Make sure text is string, trim leading and trailing spaces $strText = $($txt | out-string).Trim() #region Import the Assemblies Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing #endregion #region Generated Form Objects $DisplayForm = New-Object System.Windows.Forms.Form $textBox = New-Object System.Windows.Forms.TextBox #endregion Generated Form Objects #---------------------------------------------- #region Edited Generated Form Code $System_Drawing_Size = New-Object System.Drawing.Size(950, 600) $DisplayForm.ClientSize = $System_Drawing_Size $DisplayForm.Name = "DisplayForm" $DisplayForm.StartPosition = "CenterScreen" $DisplayForm.Text = $title $DisplayForm.AutoScale = $true $textBox.Dock = 5 $System_Drawing_Point = New-Object System.Drawing.Point(1, 1) $textBox.Location = $System_Drawing_Point $textBox.Multiline = $True $textBox.Name = "textBox" $textBox.ScrollBars = 3 #From above $textBox.Size = $System_Drawing_Size $textBox.TabIndex = 0 $textBox.Text = $strText.trim() $textbox.AutoSize = $true $Font = New-Object System.Drawing.Font("Courier New", 12, [System.Drawing.FontStyle]::Regular) $textBox.Font = $Font #This bit de-selects text in box if ($displayForm.CanFocus) { $DisplayForm.Focus() } else { $DisplayForm.Select() } $DisplayForm.Controls.Add($textBox) #endregion Edited Generated Form Code $DisplayForm.ShowDialog() | Out-Null } } Try { $data = invoke-command -ErrorAction stop -computername $ComputerName -ScriptBlock { systeminfo /fo list } } Catch { $data = $Error[0].exception.message } $data | Out-TextBox -Title "$computername System Information"