Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PowerShell-output the execution result like Log

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Recently, I have been using Powershell to complete some daily work that I often have to do. I want to get the implementation results in real time, just like Linux installation software, which can be output to the console in real time, so that I can clearly see the implementation results of each step. The format looks like this:

PS > 02Blue28 Checking xxx service.... at 13:35:43 in 2018

02/28/2018 13:35:44 xxx service is stopped.

02/28/2018 13:35:45 Starting xxx service....

02/28/2018 13:35:46 xxx service is started.

I am also a beginner in PowerShell. At first, in order to achieve this time real-time display, I used a very stupid method, which is to define a time variable in front of each output statement, which is too tedious, and there must be a simple way to achieve it. Asked the master in the group, and sure enough. PowerShell has a way to define variables directly like this: $(PowerShell-Command).

For example: $(Get-Date)

You can just use it. Here is a complete example:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report