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

 
Keymaster
6 months, 2 weeks ago.

  • Author
    Posts
  • #111416

    Participant
    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

    Participant
    Points: 1,633
    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.

    [system.uri]::new('\\servername.domain.cc').Host
    '\\servername.domain.cc'.TrimStart('\\')
    ('\\servername.domain.cc' -split '\\')[-1]
    

    From the question, I could guess that you need some basic learning in PowerShell, You can always start from
    https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-second-edition

    • #111440

      Participant
      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

    Participant
    Points: 457
    Helping Hand
    Rank: Contributor

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

    https://www.github.com/vexx32/pskoans

  • #111557

    Keymaster
    Points: 1,811
    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.

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