Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the actual combat experience of Windows PowerShell?

Shulou Source: shulou.com Published: 2022-06-02 03:48:31 10月02日 Update

Today, I would like to talk to you about the actual combat experience of Windows PowerShell, which may not be well understood by many people. in order to make you understand better, the editor summed up the following for you. I hope you can gain something according to this article.

Task 1:

Look for Cmdlet with random birth numbers.

Answer:

Get-Random

Task 2:

Find the Cmdlet that displays the current time and date

Answer:

Get-Date

Task 3:

What is the type of object generated by the Cmdlet of Task # 2?

Answer:

Get-Date | gm

Object type: TypeName:System.Diagnostics.Process

Task 4:

Use Cmdlet and Select-object in Task # 2 to show only the day of the week, as shown in the following example:

DayOfWeek

-

Monday

Answer:

(get-date). Dayofweek

Task 5:

Find the Cmdlet that can display the installed patch (hotfix)

Answer:

Get-hotfix

Task 6:

Use the Cmdlet of Task # 5 to display a list of installed patches, sort the list by installation date, and display only the following columns: installation date, patch ID, installation user.

Answer:

Get-HotFix | Select-Object-Property InstalledOn,Hotfixid,installedby | Sort-Object installedon

Task 7:

Repeat task # 6, but this time sort the results according to the patch description, output the description, patch ID, installation date column, and finally save the results to the HTML file.

Answer:

Get-HotFix | Select-Object-Property Description,hotfixid,installedon | Sort-Object Description | ConvertTo-Html > Hotfix.html

Task 8:

Display the latest 50 lists from the security event log (if the security event list is empty, you can also use other logs, such as system or application logs). The logs are sorted in ascending order of time, and also sorted by index. Displays the index, time, and source of each record. Save this information in a text file (not a HTML file, but a plain text file).

Answer:

Get-EventLog-LogName Security-Newest 50 | Sort-Object-Property TimeWritten,index | Select-Object-Property index,TimeWritten,source | Out-File security.txt

Note:

The name of the Time property is incorrect. You need to use the GM parameter to see what its real property is.

After reading the above, do you have any further understanding of Windows PowerShell's actual combat experience? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Tasks answers patches files logs dates content time sorting actual combat experience security events objects properties text types indexes results no Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Apple Huawei Shulou Information