beginner question

Welcome Forums General PowerShell Q&A beginner question

This topic contains 1 reply, has 2 voices, and was last updated by

5 years, 4 months ago.

  • Author
  • #12027

    Points: 0
    Rank: Member

    I am trying to type the following:
    $a = get content myfile.txt
    $a | foreach (get-hotfix -computername $_ | sort installedon)[-1]
    what am I doing wrong?
    if I type:
    (get-hotfix -computername thename | sort installedon)[-1]
    works great
    sorry if dump question, just begining.
    /s/ Frank in Florida

  • #12030

    Points: 0
    Rank: Member

    ForEach-Object takes (at least) one ScriptBlock parameter, and ScriptBlocks have curly braces around them (which are missing in your code). You also appear to be missing a hyphen in the Get-Content cmdlet. For example:

    Get-Content -Path MyFile.txt |
    ForEach-Object {
        Get-Hotfix -ComputerName $_ |
        Sort-Object InstalledOn

The topic ‘beginner question’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort