Ignore some output

Welcome Forums General PowerShell Q&A Ignore some output

This topic contains 4 replies, has 4 voices, and was last updated by

9 months, 1 week ago.

  • Author
  • #111416

    Topics: 3
    Replies: 4
    Points: 0
    Rank: Member

    I need to pull out all the Software update point in the Infra. Importing the module for sccm and using "Get-CMSoftwareUpdatePoint", gets me to the point where I get whats required. However the output is as below:-

    SmsProviderObjectPath :

    FileType              : 2

    ItemName              :

    ItemType              : System Resource Usage

    NALPath               :

    NALType               :

    NetworkOSPath         : \\servername.domain.cc

    PropLists             : {Objects Polled By Site Status}

    Props                 : {AnonymousProxyAccess, DBServerName, Enabled, IsINF...}

    RoleCount             : 7

    RoleName              : SMS Software Update Point

    ServerState           : 196611

    ServiceWindows        :

    SiteCode              :

    SiteSystemStatus      : 1

    SslState              : 0

    Type                  : 2


    I can pipe it to use "NetworkOSPath", but the output is \\servername.domain.cc. I want the output without \\ so that I can query it directly to the server.

    example: servername.domain.cc


  • #111434

    Topics: 8
    Replies: 878
    Points: 2,690
    Helping Hand
    Rank: Community Hero

    To what cmdlet are you planning to pipe it, If there is a cmdlet which accepts pipeline input for this NetworkOSPath by value/type it will work without any modifications. However for you query, you can do it in may ways, below are few.

    ('\\servername.domain.cc' -split '\\')[-1]

    From the question, I could guess that you need some basic learning in PowerShell, You can always start from

    • #111440

      Topics: 3
      Replies: 4
      Points: 0
      Rank: Member

      Thanks. I got this corrected using replace options.

      $computername= (Get-CMSoftwareUpdatePoint -allsite).NetworkOSPath -replace "\\"

      Powershell, really vast. though i have gone through some tutorial. I tend to miss out here and there. Thanks for the link, I will go through it.



  • #111452

    Topics: 2
    Replies: 442
    Points: 918
    Helping Hand
    Rank: Major Contributor

    Depending on your learning style, you may also find some use out of the koans I'm working on:


  • #111557

    Topics: 13
    Replies: 4872
    Points: 1,812
    Helping HandTeam Member
    Rank: Community Hero

    Look for the Third Edition of the book, it's newer. http://donjones.com/powershell has a link. The 4N00bs book in particular might be helpful, as it's extremely concise (short read) and covers the major under-the-hood gotchas, like this, that trip people up the most.

    And what you're likely looking for is Select-Object. What your command is producing isn't textual output; it's an object, which has properties. Select-Object lets you specify which ones you want included in the output.

The topic ‘Ignore some output’ is closed to new replies.