Help with Inventory PS Code

Welcome Forums General PowerShell Q&A Help with Inventory PS Code

Viewing 2 reply threads
  • Author
    Posts
    • #208167
      Participant
      Topics: 2
      Replies: 4
      Points: 33
      Rank: Member

      Hi,

      I can get the Hostname, Serial and Mac from the following, but wondered if there is a better way to structure the PS?

      Get-ComputerInfo | Select-Object -Property BiosSeralNumber,CSDnsHostName,{Get-NetAdapter -Name Ethernet | Select MacAddress}

      Regards

      Tony

       

    • #208185
      Participant
      Topics: 10
      Replies: 2480
      Points: 6,537
      Helping Hand
      Rank: Community MVP

      Maybe not a better structure but a probably slightly faster way as Get-ComputerInfo used to be very slow: 😉

      To learn best practices and styles you could read up The Unofficial PowerShell Best Practices and Style Guide.

      BTW: When you post code please format this as code using the code tag button named “PRE“. Thanks.

    • #208257
      Participant
      Topics: 2
      Replies: 4
      Points: 33
      Rank: Member

      Thanks Olaf, that works nicely and the output is certainly more attractive than my code.

      I will start reading through the guide, cheers for helping out here.

Viewing 2 reply threads
  • The topic ‘Help with Inventory PS Code’ is closed to new replies.