Welcome › Forums › General PowerShell Q&A › GetEventlog code question
This topic contains 3 replies, has 3 voices, and was last updated by
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.
If you like run this cmdlet for your local computer you don't need the parameter -ComputerName. What's your computername?
What is your computername is a good question as it may have escape characters. Can you try this?
Get-EventLog Security -Computer $env:COMPUTERNAME
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"
The topic ‘GetEventlog code question’ is closed to new replies.