Question: Exercise 1: Run the following Commands and Scripts 1. Pipe Formating get-service |format-list displayname, status, requiredservices get-service |format-table displayname, status, requiredservices |sort-object -property status get-service
Exercise 1: Run the following Commands and Scripts
1. Pipe Formating
get-service |format-list displayname, status, requiredservices
get-service |format-table displayname, status, requiredservices |sort-object -property status
get-service |sort-object -property status | format-list displayname, status, requiredservices
get-service |out-gridview
get-service |select-object displayname, status, requiredservices | out-gridview
2. Implementing Get-Process
Get-Process | Format-Table
Get-Process -Name powershell | Format-Table
(Note that data often gets truncated)
Department of Computer Science Spring 2019
Get-Process -Name powershell | Format-Table -Property Path,Name,Id,Company
(The Autosize parameter displays as much info as possible beginning with the leftmost columns)
Get-Process -Name powershell | Format-Table -Property Path,Name,Id,Company -AutoSize
(To see more of a certain column, move it to the left)
Get-Process -Name powershell | Format-Table -PropertyCompany,Name,Id,Path -AutoSize
(The Wrap parameter will prevent truncated data)
Get-Process -Name powershell | Format-Table -Wrap -Property Name,Id,Company,Path
(The GroupBy parameter groups output based on a property value)
Get-Process -Name powershell | Format-Table -Wrap -AutoSize -Property Name,Id,Path - GroupBy Company
3. Output to HTML Example
get-service | where-object {$_.status -eq "running"} | ConvertTo-HTML Name, DisplayName, Status | Set-Content C:\svc.html
4. .NET Integration (Windows Forms Example)
[void][reflection.assembly]::LoadWithPartialName( "System.Windows.Forms") $form = new-object Windows.Forms.Form $form.Text = "My First Form" $button = new-object Windows.Forms.Button $button.text="Push Me!" $button.Dock="fill" $button.add_click({$form.close()}) $form.controls.add($button) $form.Add_Shown({$form.Activate()}) $form.ShowDialog()
SHOW SCREEN SHOTS OF THE INPUT AND OUTPUT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
