Powershell command on domain computers as administrator

Copper Contributor



I want to execute a command on all computers in my domain but in order for it to work, it needs to run with elevated permissions.

Is there a possibility to do this?


my command:


get-winevent -filterXML([xml](Get-Content "C:\Execute\Inventorview.xml")) | sort timecreated -descending | export-csv c:\execute\result.csv




the response i get:


get-winevent : Could not retrieve information about the Security log. Error: Poging tot het uitvoeren van een niet-gema
chtigde bewerking..
At line:1 char:1
+ get-winevent -filterXML([xml](Get-Content "C:\Execute\Inventorview.xm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WinEvent], Exception
    + FullyQualifiedErrorId : LogInfoUnavailable,Microsoft.PowerShell.Commands.GetWinEventCommand




(Poging tot het uitvoeren van een niet-gemachtigde bewerking... = dutch for 'trying to execute a non-authorized...')


Thanks in advance!

3 Replies

Have you verified this command on a computer where you have administrator level access?
If it provides the information you require, it's a matter of having admin access to all computers and launching PS under that user's context. 

get-winevent has a -credential parameter you can use.

@Animesh Joshi I have verified this command with an admin account.

Can you run a scheduled task to all computers to run this script as an admin?

I'ts the first time that i'm trying anything like this so it's all kind of new for me. 



Yes you can create a scheduled task to run on any number of remote computers as long as the user context under which the command is running has required access on the remote computer.