get-winevent: unauthorized access exception on local pc.

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

get-winevent: unauthorized access exception on local pc.

Post by dan.potter »

I can't seem to find the right cause of this. I'm trying to get events out of the security log. I have UAC but it only prompts for elevation when installing software. Eventvwr does not prompt when opening the security log.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-winevent: unauthorized access exception on local pc.

Post by jvierra »

You must start PowerShell elevated before running a script. Most programs will not auto-elevate.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: get-winevent: unauthorized access exception on local pc.

Post by dan.potter »

My execution policy is set to unrestricted. I'm not running a script right now. I'm working in the shell to get the events I need first.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-winevent: unauthorized access exception on local pc.

Post by jvierra »

That has nothing to do with UAC. Look up UAC and see how it works. You can even ask Cortana.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-winevent: unauthorized access exception on local pc.

Post by jvierra »

dan.potter wrote:My execution policy is set to unrestricted. I'm not running a script right now. I'm working in the shell to get the events I need first.
The security Event log has been tagged to auto-elevate. This can be done for an EXE through CAS or in the registry.

PowerShell does not allow this. You must elevate.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: get-winevent: unauthorized access exception on local pc.

Post by dan.potter »

Gotcha. Looks like start-job retains the elevated permissions when launching the main form elevated. This works for me.
This topic is 7 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked