Try Hard to Learn Powershell Error "The Hash Literal Was Incomplete."
Get-Process s* |
    where {s$_.Path} |
    dir |
    sort LastWriteTime |
    Format-Table fullname, name,@{label="LastWriteTime";Expr={$_.LastWriteTime}

Error:

The hash literal was incomplete.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : IncompleteHashLiteral

Could You please give me a hint how to rewrite, please?

4

1 Answer

You missed a curly brace. But there's more problems in your code. It is not possible to pipe a System.Diagnostics.Process object to 'dir'

I made this, which I think gives the output you want:

Get-Process s* |where {$_.Path} | ForEach-Object {Get-Item $_.Path } |
Sort-Object LastWriteTime | Format-Table fullname, name,LastWriteTime

What it does:

  • Get all processes where the name start with an s and the returned object has the Path property defined
  • Get the file object of each process
  • sort the file objects by LastWriteTime
  • Format the output
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest