# PowerShell Logging.

**URL:** <https://forums.powershell.org/t/powershell-logging/1902>\
**Category:** PowerShell Help\
**Created:** [September 19, 2013, 7:37pm UTC](https://forums.powershell.org/t/powershell-logging/1902 "2013-09-19T19:37:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertpearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robertpearman/32/936_2.png) [@robertpearman](https://forums.powershell.org/u/robertpearman)\
**Post date:** [September 19, 2013, 7:37pm UTC](https://forums.powershell.org/t/powershell-logging/1902/1 "2013-09-19T19:37:44Z")

</div>

Hi Guys, newbie here on the forums.

I looked for an answer to my question first, so this is more of a follow up to this post:  
[https://powershell.org/forums/topic/save-the-output-of-powershell-script/](https://powershell.org/forums/topic/save-the-output-of-powershell-script/)

I use PowerShell quite a lot, but I am no means experienced with scripting/coding.

I have built, what I would class as crude PowerShell applications. A series of functions and a menu system built into a PS1 file.

What I have not been able to yet master is logging.

Just this morning I have found the â€˜start-transcriptâ€™ command, which appears to be exactly what I want.

However, inside my application I suppress the errors so the user has a more elegant experience.

My thinking here is that a transcript, is essentially going to capture whatever is output to the console, and if i have  
$ErrorAction = “SilentlyContinue” the errors wont be there to be transcripted.

What I would like to do is run a transcript but also capture the errors, whilst not displaying the errors out to the console.

Is that possible? Hopefully that makes sense?

Many thanks in advance if you are able to help out!

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [September 19, 2013, 8:14pm UTC](https://forums.powershell.org/t/powershell-logging/1902/2 "2013-09-19T20:14:02Z")

</div>

I don’t think you can.

using the transcript cmdlets toggles the transcript functionality pretty much on or off  
-Erroraction silentlycontinue will pretty much suppress your errors and you won’t see anything

I think you’ll have to log information separately - either using write-eventlog to add it to an event log - I’d recommend creating your own  
or use add-content to write the data to a text file

I think you’ll end up with something like

try {  
do-something -erroraction stop  
log success  
}  
catch  
{  
log error  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [September 19, 2013, 9:41pm UTC](https://forums.powershell.org/t/powershell-logging/1902/3 "2013-09-19T21:41:08Z")

</div>

If you have some control over how your script is called, you could also use a redirection operator to send the Error stream to a file. It would have to be a separate file from the rest of your logging, though (to avoid “file in use by another process” errors):

`.\SomeScript.ps1 2>> .\SomeScriptErrorLog.txt`

---

<div class="post-metadata">

**Author:** ![robertpearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robertpearman/32/936_2.png) [@robertpearman](https://forums.powershell.org/u/robertpearman)\
**Post date:** [September 19, 2013, 9:51pm UTC](https://forums.powershell.org/t/powershell-logging/1902/4 "2013-09-19T21:51:18Z")

</div>

Ok so that sounds doable.

I have a shortcut on the desktop of a server that launches Powershell.exe -command xxxx

What do i need to do within the script to get the errors output to a seperate file?

Rob.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [September 19, 2013, 9:54pm UTC](https://forums.powershell.org/t/powershell-logging/1902/5 "2013-09-19T21:54:45Z")

</div>

You could add that same redirection operator to the shortcut. PowerShell.exe -command xxxx 2\>\> .\SomeErrorLog.txt

---

<div class="post-metadata">

**Author:** ![robertpearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robertpearman/32/936_2.png) [@robertpearman](https://forums.powershell.org/u/robertpearman)\
**Post date:** [September 19, 2013, 10:04pm UTC](https://forums.powershell.org/t/powershell-logging/1902/6 "2013-09-19T22:04:34Z")

</div>

2\>\> .\SomeErrorLog.txt

What exactly does this tell Powershell to do? (i understand the file name bit ;o) )

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [September 20, 2013, 12:32am UTC](https://forums.powershell.org/t/powershell-logging/1902/7 "2013-09-20T00:32:59Z")

</div>

It redirects the Error stream to a file (appending to the file if it already exists). “Get-Help about\_Redirection” has the details how those operators all work.

---

<div class="post-metadata">

**Author:** ![robertpearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/robertpearman/32/936_2.png) [@robertpearman](https://forums.powershell.org/u/robertpearman)\
**Post date:** [September 20, 2013, 1:07am UTC](https://forums.powershell.org/t/powershell-logging/1902/8 "2013-09-20T01:07:35Z")

</div>

OK i will check it out, many thanks.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/powershell-logging/1902/9 "2024-05-16T20:57:01Z")

</div>


