Try hard to learn PowerShell error “The hash literal was incomplete.”












0















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?










share|improve this question




















  • 2





    how many open curly braces do you have and how many closing?

    – Martin Smith
    Dec 30 '18 at 11:45











  • Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

    – Ansgar Wiechers
    Dec 30 '18 at 11:52






  • 1





    The term 's$_.Path' is not recognized…

    – JosefZ
    Dec 30 '18 at 11:55











  • If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

    – Andrew Morton
    Dec 30 '18 at 12:09
















0















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?










share|improve this question




















  • 2





    how many open curly braces do you have and how many closing?

    – Martin Smith
    Dec 30 '18 at 11:45











  • Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

    – Ansgar Wiechers
    Dec 30 '18 at 11:52






  • 1





    The term 's$_.Path' is not recognized…

    – JosefZ
    Dec 30 '18 at 11:55











  • If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

    – Andrew Morton
    Dec 30 '18 at 12:09














0












0








0








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?










share|improve this question
















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?







powershell syntax-error






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 11:51









Ansgar Wiechers

142k13128185




142k13128185










asked Dec 30 '18 at 11:40









Konrad KeyKonrad Key

31




31








  • 2





    how many open curly braces do you have and how many closing?

    – Martin Smith
    Dec 30 '18 at 11:45











  • Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

    – Ansgar Wiechers
    Dec 30 '18 at 11:52






  • 1





    The term 's$_.Path' is not recognized…

    – JosefZ
    Dec 30 '18 at 11:55











  • If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

    – Andrew Morton
    Dec 30 '18 at 12:09














  • 2





    how many open curly braces do you have and how many closing?

    – Martin Smith
    Dec 30 '18 at 11:45











  • Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

    – Ansgar Wiechers
    Dec 30 '18 at 11:52






  • 1





    The term 's$_.Path' is not recognized…

    – JosefZ
    Dec 30 '18 at 11:55











  • If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

    – Andrew Morton
    Dec 30 '18 at 12:09








2




2





how many open curly braces do you have and how many closing?

– Martin Smith
Dec 30 '18 at 11:45





how many open curly braces do you have and how many closing?

– Martin Smith
Dec 30 '18 at 11:45













Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

– Ansgar Wiechers
Dec 30 '18 at 11:52





Your calculated property is missing a closing curly bracket: @{label="...";Expr={...} -> @{label="...";Expr={...}}

– Ansgar Wiechers
Dec 30 '18 at 11:52




1




1





The term 's$_.Path' is not recognized…

– JosefZ
Dec 30 '18 at 11:55





The term 's$_.Path' is not recognized…

– JosefZ
Dec 30 '18 at 11:55













If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

– Andrew Morton
Dec 30 '18 at 12:09





If you used something like the Windows PowerShell Integrated Scripting Environment (ISE) it would give you hints about missing }s and so on.

– Andrew Morton
Dec 30 '18 at 12:09












1 Answer
1






active

oldest

votes


















1














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






share|improve this answer


























  • If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

    – Andrew Morton
    Dec 30 '18 at 12:43











  • @AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 13:16











  • I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

    – Andrew Morton
    Dec 30 '18 at 13:20











  • Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

    – Konrad Key
    Dec 30 '18 at 14:01











  • I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 14:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53977293%2ftry-hard-to-learn-powershell-error-the-hash-literal-was-incomplete%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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






share|improve this answer


























  • If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

    – Andrew Morton
    Dec 30 '18 at 12:43











  • @AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 13:16











  • I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

    – Andrew Morton
    Dec 30 '18 at 13:20











  • Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

    – Konrad Key
    Dec 30 '18 at 14:01











  • I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 14:01
















1














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






share|improve this answer


























  • If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

    – Andrew Morton
    Dec 30 '18 at 12:43











  • @AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 13:16











  • I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

    – Andrew Morton
    Dec 30 '18 at 13:20











  • Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

    – Konrad Key
    Dec 30 '18 at 14:01











  • I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 14:01














1












1








1







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






share|improve this 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







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 31 '18 at 12:46









Chui Tey

4,35922536




4,35922536










answered Dec 30 '18 at 12:11









Gert Jan KraaijeveldGert Jan Kraaijeveld

58016




58016













  • If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

    – Andrew Morton
    Dec 30 '18 at 12:43











  • @AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 13:16











  • I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

    – Andrew Morton
    Dec 30 '18 at 13:20











  • Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

    – Konrad Key
    Dec 30 '18 at 14:01











  • I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 14:01



















  • If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

    – Andrew Morton
    Dec 30 '18 at 12:43











  • @AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 13:16











  • I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

    – Andrew Morton
    Dec 30 '18 at 13:20











  • Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

    – Konrad Key
    Dec 30 '18 at 14:01











  • I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

    – Gert Jan Kraaijeveld
    Dec 30 '18 at 14:01

















If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

– Andrew Morton
Dec 30 '18 at 12:43





If it is not possible to pipe a System.Diagnostics.Process object to 'dir', how does it nevertheless work?

– Andrew Morton
Dec 30 '18 at 12:43













@AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

– Gert Jan Kraaijeveld
Dec 30 '18 at 13:16





@AndrewMorton In my code the process object(s) are piped to Foreach-Object that gets a file object foreach process that is passed by invoking Get-Item, using the path property of the process object.

– Gert Jan Kraaijeveld
Dec 30 '18 at 13:16













I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

– Andrew Morton
Dec 30 '18 at 13:20





I tried your code and the OP's corrected code, and both gave me the same output (PS version 5.1). I was wondering why the OP's code works with dir.

– Andrew Morton
Dec 30 '18 at 13:20













Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

– Konrad Key
Dec 30 '18 at 14:01





Thank You very much, indeed i missed } and added unfortunately {s$_.Path}

– Konrad Key
Dec 30 '18 at 14:01













I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

– Gert Jan Kraaijeveld
Dec 30 '18 at 14:01





I didn't even test the code piping to dir :-) It was clear to me that wouldn't work. I was wrong. I see it works. Wow! The explanation here is, to me, an almost incredible flexibility of the dir (Get-ChildItem) cmdlet

– Gert Jan Kraaijeveld
Dec 30 '18 at 14:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53977293%2ftry-hard-to-learn-powershell-error-the-hash-literal-was-incomplete%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'