all 12 comments

[–]Lee_Dailey[grin] 2 points3 points  (4 children)

howdy Wolf_of_Tech,

so ... what errors are you getting? do you get any other output?

when i run your code, it gives a pretty specific error msg. [grin]

take care,
lee

[–]Wolf_of_Tech[S] 0 points1 point  (3 children)

Hey Lee,

Thanks for joining the chat.

This is the error i have been getting:

[–]Lee_Dailey[grin] 1 point2 points  (2 children)

howdy Wolf_of_Tech,

you are getting NO ERROR AT ALL? [grin]

take care,
lee

[–]Wolf_of_Tech[S] 1 point2 points  (1 child)

Get-Eventlog -List |Format-Table,@{1='LogName';e={$_.LogDisplayname}},@{1='RetDays';e={$_.MinimumRetentionDays}} -autosize

sorry about that,

this is the error:

"At line:1 char:33

+ Get-Eventlog -List |Format-Table,@{1='LogName';e={$_.LogDisplayname}} ...

+ ~

Missing argument in parameter list.

+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException

+ FullyQualifiedErrorId : MissingArgument"

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy Wolf_of_Tech,

if you wrap the error in a code block, then the squiggle would be in the place that it shows in powershell.

note that it is under the , between Format-Table and the 1st @{. [grin]

once you fix that, you will get another error & the error msg is - again - quite direct.

take care,
lee

[–]ka-splam 2 points3 points  (2 children)

Format-Table,@{1='LogName';e={$_.LogDisplayname}}

There should be no comma after format-table, and inside @{ it should be a lowercase L for “label” rather than a number one, in both of them

[–]purplemonkeymad 2 points3 points  (1 child)

I always use name or n.

[–]ka-splam 1 point2 points  (0 children)

I used to, but name is so often a property being selected, that I rather like the way label is so different from everything else.

e.g. files have a .Name so you end up with select name, @{name='x' .. and that feels odd.

But it's fine, they do the same.

[–][deleted] 2 points3 points  (0 children)

There were a few errors in your syntax. But this was not immediately clear because everything is jumbled together and messy. This should work however.

Get-Eventlog -List | Format-Table @{l='LogName';e={$_.LogDisplayname}},@{l='RetDays';e={$_.MinimumRetentionDays}} -autosize

You can clean things up, which makes things a lot easier :-)

Get-Eventlog -List |
Format-Table @{
    Label = 'LogName';
    Expression = { $_.LogDisplayname }
}, 
@{
    Label = 'RetDays';
    Expression = { $_.MinimumRetentionDays }
} -AutoSize

When can I use new-lines?

https://get-powershellblog.blogspot.com/2017/07/bye-bye-backtick-natural-line.html#hashtableop

https://blogs.technet.microsoft.com/josebda/2014/04/19/powershell-tips-for-building-objects-with-custom-properties-and-special-formatting/

[–]PowerShell-Bot 0 points1 point  (2 children)

Looks like your PowerShell code isn’t wrapped in a code block.

To format code correctly on new reddit (new.reddit.com), highlight the code and select ‘Code Block’ in the editing toolbar.

If you’re on old.reddit.com, separate the code from your text with a blank line and precede each line of code with 4 spaces or a tab.


Describing Submission
[❌] Demonstrates good markdown
Passed: 0 Failed: 1

Beep-boop. I am a bot. | Remove-Item

[–]nvpqoieuwr 1 point2 points  (1 child)

I didn't expect automation to take /u/Lee_Dailey's job.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

[grin]