2

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?

  • Where you output it ? I suggest the temp folder to prevent access error – yagmoth555 Jun 16 '17 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? – frankhammer Jun 16 '17 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 – yagmoth555 Jun 16 '17 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. – frankhammer Jun 16 '17 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 – yagmoth555 Jun 16 '17 at 16:19
2

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.

-2

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

[Your Content]

Stop-Transcript

  • This doesn't look helpful at all, but OP didn't specify his not working code, so this would be a working example, neverless. – bjoster Apr 23 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.