How to create a dynamic variable in Powershell, sucha as date/time etc

后端 未结 5 943
太阳男子
太阳男子 2020-12-22 08:20

Hi i am not exactly sure if my wording is right but i need a variable which contains current date/time whenever i write data to log ; how can i do that with

5条回答
  •  温柔的废话
    2020-12-22 08:42

    wrap your two commands in function so you will have just one call ?

    function add-log{
    (param $txt)
    $DateTime = get-date  | select -expand datetime
    Add-Content $LogFile -Value "$DateTime: $txt"
    }
    

提交回复
热议问题