none
What is -band? RRS feed

  • Question

  • In the following linked script, I'm having trouble understanding what the parameter -band is referring to.  I've done some google and get-help searches, but am not able to find any information.  Is anyone familiar with this "-band" parameter, or link me to a page with some information on it?

    https://gallery.technet.microsoft.com/Forensics-Audit-Group-f9c57a1d

    Wednesday, August 9, 2017 2:56 PM

Answers

  • Hi,

    sure thing: It's the Binary And operator. When comparing two numbers, it'll convert them both to binary and compare their digits. Those it returns the number with all the digits both have set to 1.

    I think an example would be best here ...

    13 -band 7
    # returns 5

    7 in binary is "111"
    13 in binary is "1101"
    Their common digits are thus "101" (or 5)

    Cheers,
    Fred

    Edit: No, computers don't really convert them to binary - they already think that way


    There's no place like 127.0.0.1


    • Edited by FWN Wednesday, August 9, 2017 3:26 PM
    • Marked as answer by MatchesMalone Wednesday, August 9, 2017 4:33 PM
    Wednesday, August 9, 2017 3:26 PM
  • -band means "bitwise and".

    An intro to binary math in computer science will explain how the -band, -bor, -bxor, and -bnot operators work. In fact, the PowerShell help has a basic intro in the about_Comparison_Operators help topic (under the section titled Bitwise Operators):


    PS C:\> help about_Comparison_Operators


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by MatchesMalone Thursday, August 10, 2017 2:02 PM
    Wednesday, August 9, 2017 4:27 PM
    Moderator

All replies

  • Hi,

    sure thing: It's the Binary And operator. When comparing two numbers, it'll convert them both to binary and compare their digits. Those it returns the number with all the digits both have set to 1.

    I think an example would be best here ...

    13 -band 7
    # returns 5

    7 in binary is "111"
    13 in binary is "1101"
    Their common digits are thus "101" (or 5)

    Cheers,
    Fred

    Edit: No, computers don't really convert them to binary - they already think that way


    There's no place like 127.0.0.1


    • Edited by FWN Wednesday, August 9, 2017 3:26 PM
    • Marked as answer by MatchesMalone Wednesday, August 9, 2017 4:33 PM
    Wednesday, August 9, 2017 3:26 PM
  • -band means "bitwise and".

    An intro to binary math in computer science will explain how the -band, -bor, -bxor, and -bnot operators work. In fact, the PowerShell help has a basic intro in the about_Comparison_Operators help topic (under the section titled Bitwise Operators):


    PS C:\> help about_Comparison_Operators


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by MatchesMalone Thursday, August 10, 2017 2:02 PM
    Wednesday, August 9, 2017 4:27 PM
    Moderator