combining output from two commands

Welcome Forums General PowerShell Q&A combining output from two commands

Viewing 2 reply threads
  • Author
    Posts
    • #45186
      Participant
      Topics: 2
      Replies: 2
      Points: 0
      Rank: Member

      Ok, I’m trying to learn, and I usually do that by kludging pieces of other’s code together to make it work for my purposes. What I’d like to do (converting to html or not) is combine specific fields of get-fsrmquota and a query of share info into one ‘report’. while this only looks at 1 computer, I’d like to do it for a list with the option of 1 big output, or 1 output for each computer in the list ala ForEach ($system in Get-Content “c:\temp\systems.txt”
      I’m sure there are syntax usage errors in this also (ie, semicolon versus comma)
      Any help given is greatly appreciated.

      Err:
      New-Object : Cannot convert ‘System.Object[]’ to the type ‘System.Collections.IDictionary’ required by parameter ‘Property’. Specified method is not supported.
      At \\site-it-fs\root\DDOAdmin\Scripts\Powershell\Quota-ShareInfo\Combined_quota-shareinfo-html.ps1:97 char:54
      + $tableinfo = New-Object -TypeName psobject -Property $combinedinfo
      + ~~~~~~~~~~~~~
      + CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
      + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.NewObjectCommand

    • #45192
      Keymaster
      Topics: 18
      Replies: 4872
      Points: 1,903
      Helping HandTeam Member
      Rank: Community Hero

      So, have you read our HTML Reporting book (Ebooks menu)? It tackles pretty much this exact topic in a fairly methodical way – and i think it’ll mean less work for you.

      The problem is that $combinedinfo isn’t a hashtable.

      $combinedInfo = @{ ‘Property’ = ‘Value’
      ‘Property’ = ‘Value’
      ‘Property’ = ‘Value’
      }

      Is what I’d expect. But you’ve just supplied values, and you’ve one it as an array of objects. I’ll also recommend “Learn PowerShell Toolmaking in a Month of Lunches.” It really explains the whys and hows of what you’re after, and it’ll set you on a pth toward doing it right, in terms of making your code PowerShell-friendly.

    • #45196
      Participant
      Topics: 2
      Replies: 2
      Points: 0
      Rank: Member

      I’ll definitely take a look. thanks for the heads up.

Viewing 2 reply threads
  • The topic ‘combining output from two commands’ is closed to new replies.