Email: support@essaywriterpros.com
Call Us: US - +1 845 478 5244 | UK - +44 20 7193 7850 | AUS - +61 2 8005 4826

the Convert To-HTML command

ConvertTo-HTML

When using PowerShell, you might want to generate a report about the information you’ve seen. One of the best ways to do this is by using the ConvertTo-HTML command. This cmdlet allows you to build reports with tables and colour, which can help to visualize complex data. Simply choose an object and add it to the command. For example, you could type:

Get-PSDrive | ConvertTo-Html

This returns a mass of information, so it’s a good idea to limit it to a file with the Out-File command. A better alternative command is:

Get-PSD Drive | ConvertTo-Html | Out-File -FilePath PSDrives.html

This will then generate an html file in table form. For example:

powershell html table

You can then add your own colours and borders to refine its presentation.

Export-CSV (and Get-Service)

No less important for increasing visibility is the Export-CSV command. It allows you to export PowerShell data into a CSV file. Essentially, this command creates a CSV file compiling all of the objects you’ve selected in PowerShell. Every object has its own line or row within the CSV file. This command is primarily used to create spreadsheets and share data with external programs.

To use this command, you would type:

PS C:\> Get-Service | Export-CSV c:\service.csv

It’s important to remember not to format objects before running the Export-CSV command. This is because formatting objects results in only the formatted properties being placed into the CSV file rather than the original objects themselves. In the event that you want to send specific properties of an object to a CSV file, you would use the Select-Object cmdlet.

To use the Select-Objectcmdlet, type:

PS C:\> Get-Service | Select-Object Name, Status | Export-CSV c:\Service.csv

Get-Process

If you want to view all processes currently running on your system, the Get-Process command is very important. To get a list of all active processes on your computer, type:

PS C:\ Get-Process

Notice that if you don’t specify any parameters, you’ll get a breakdown of every active process on your computer. To pick a specific process, narrow the results down by process name or process ID and combine that with the Format-Listcmdlet, which displays all available properties. For example:

PS C:\ Get-Process windowrd, explorer | Format-List *

This provides you with comprehensive oversight of all active processes.

Get-EventLog

get eventlog security cmdlet

If you ever want to access your computer’s event logs (or logs on remote computers) while using PowerShell, then you’re going to need the Get-EventLog command. This cmdlet only works on classic event logs, so you’ll need the Get-WinEvent command for logs later than Windows Vista.