How to get multiple values from remote machine (Invoke-Command)

Welcome Forums General PowerShell Q&A How to get multiple values from remote machine (Invoke-Command)

Viewing 2 reply threads
  • Author
    Posts
    • #242735
      Participant
      Topics: 9
      Replies: 11
      Points: 141
      Rank: Participant

      Hello,

      I try to make script to inventory my computers in LAN. I wrote script to get processor, RAM and HDD values:

      But in result I don’t have all values what I want but only computer name, one value and RunSpaceID.

      Procesor PSComputerName RunspaceId ——– ————– ———- Processor_name computer1 some_Runspace Processor_name computer2 some_Runspace Processor_name computer3 some_Runspace If I’ll comment line responsible for getting processor value from computer then RAM value will appear. The same is with HDD. But how can I make to get all this values at one time? Best Regards Daniel

      • This topic was modified 2 months, 1 week ago by kolaborek08. Reason: Text formatting
    • #257918
      Participant
      Topics: 0
      Replies: 39
      Points: 386
      Helping Hand
      Rank: Contributor

      Hello kolaborek08,

      Inside your Script block you need to create PSCustom object and return it.

      Reference: https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-pscustomobject?view=powershell-7

      Right now you are returning only remote computer name.

      Hope that helps.

      • This reply was modified 5 days, 2 hours ago by AndySvints.
      • This reply was modified 5 days, 2 hours ago by AndySvints.
      • This reply was modified 4 days, 10 hours ago by grokkit.
    • #258101
      Participant
      Topics: 5
      Replies: 330
      Points: 530
      Helping Hand
      Rank: Major Contributor
Viewing 2 reply threads
  • You must be logged in to reply to this topic.