6

I have a Powershell Script which install and updates Software via the Windows Package Manager Chocolatey.

If I execute my PS-Script as a user, everything is fine. So there has to be another issue like an restricting Execution Policy (this is set to unrestricted via GPO).

How do I get the Output of the Powershell? I am using Start-Transcript but I cannot find the output file anywhere and if I specify the path it doesn't create the log file...

The Powershell-Script executes during startup as machine GPO.

Are there other options to debug, I havent thought of?

7
  • 1
    Where you output it ? I suggest the temp folder to prevent access error Commented Jun 16, 2017 at 11:42
  • C:\output.txt I thought of an access error, but Powershell scripts executed by machine GPO should have local administrator privileges or am I wrong? Commented Jun 16, 2017 at 11:43
  • It would be, but I wanted to be sure its not in a share access the log. Does your new gpo run? gpresult /h:t.htm Commented Jun 16, 2017 at 12:47
  • Yes it does. I think it is an issue with chocolatey running under the local system account. So getting the output Is the goal I think. Commented Jun 16, 2017 at 14:40
  • maybe create a new test gpo, create a .bat that will start your powershell command with the output to text in the .bat (./ps.ps1 >>c:\test.txt) You will see the error powershell might give Commented Jun 16, 2017 at 16:19

2 Answers 2

4

Problem was very stupid... I had added the Powershell Script in the Scripts Section not in the Powershell Scripts Section while in the Properties of Startup-Scripts...

I found out, that Start-Transcript does not create a logfile when executed as SYSTEM-Account (during Startup). You have to specify a path, then it creates the logfile. Sorry and thank you for your help.

-1

Start-Transcript -Path "$($env:windir)\Temp\Logon.txt" -Force

[Your Content]

Stop-Transcript

2
  • This doesn't look helpful at all, but OP didn't specify his not working code, so this would be a working example, neverless. Commented Apr 23, 2019 at 11:22
  • I wish it recorded the debug stream. You can't say "> log 2>&1" as a parameter with implied "powershell -file". Commented Jun 27, 2024 at 15:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.