 <p>wrap your two commands in function so you will have just one call ?</p> <pre><code>function add-log{ (param $txt) $DateTime = get-date | select -expand datetime Add-Content $LogFile -Value "$DateTime: $txt" } </code></pre>