Author Posts

December 10, 2016 at 6:17 pm

I'm using PS 5.0 for this code:

 Get-Eventlog security -ComputerName 

and putting my computer's name after -ComputerName, and getting this error:

Get-EventLog : Missing an argument for parameter 'ComputerName'. Specify a parameter of type
'System.String[]' and try again.
At line:1 char:23
+ Get-Eventlog security -ComputerName
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-EventLog], ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.GetEventLogCommand

The code is from PS in a Month of Lunches, 2e, page 31.

I'm not understanding why the code isn't working as written in the book, nor am I understanding what the error is, as I should be opening the security log for my computer.

Thanks for you help.

December 10, 2016 at 7:42 pm

If you like run this cmdlet for your local computer you don't need the parameter -ComputerName. What's your computername?

December 10, 2016 at 8:30 pm

What is your computername is a good question as it may have escape characters. Can you try this?

Get-EventLog Security -Computer $env:COMPUTERNAME 

December 10, 2016 at 8:38 pm

Ahhh ... I gues I got it. If you like to use the parameter -ComputerName you have to put your computername after the parameter name. Like this:

 Get-Eventlog security -ComputerName "MyComputerName"