Coder Social home page Coder Social logo

Comments (3)

msftrncs avatar msftrncs commented on August 21, 2024

Hi, @kyjdp. The output is correct.

Patches is an array, and in PowerShell when you reference members within an array without specifying the array index, you get all of them.

There are 13 members in the array:

$plist.ACPI.DSDT.Patches.Length

Try this command, to see them all separately using Format-Hex

$plist.ACPI.DSDT.Patches.foreach{ $_.Find | Format-Hex }

or reference each one

$plist.ACPI.DSDT.Patches[0].Find | Format-Hex
$plist.ACPI.DSDT.Patches[1].Find | Format-Hex
# and so on...

from pwshreadxmlplist.

Davider-code avatar Davider-code commented on August 21, 2024

Hi, @kyjdp. The output is correct.

Patches is an array, and in PowerShell when you reference members within an array without specifying the array index, you get all of them.

There are 13 members in the array:

$plist.ACPI.DSDT.Patches.Length

Try this command, to see them all separately using Format-Hex

$plist.ACPI.DSDT.Patches.foreach{ $_.Find | Format-Hex }

or reference each one

$plist.ACPI.DSDT.Patches[0].Find | Format-Hex
$plist.ACPI.DSDT.Patches[1].Find | Format-Hex
# and so on...

@msftrncs
Hello, thank you for your reply
Sometimes I need to look at the actual values of these arrays because I want to modify them
Is there a way to fix this problem? Thank you in advance

PS:
In PowerShell programming language, I spent a lot of time looking for functions to modify plist files. Your function is the only and most powerful,
Thank you for your great work

from pwshreadxmlplist.

msftrncs avatar msftrncs commented on August 21, 2024

Sometimes I need to look at the actual values of these arrays because I want to modify them
Is there a way to fix this problem? Thank you in advance

There is one thing that complicates these arrays. When you query the Find property without specifying the index to the Patches array, the result is an array of an array of bytes and PowerShell will just concatenate them together in to a single array of bytes. To modify them, you must process each element of the Patches array separately, such as using the .foreach special method, the ForEach-Object special commandlet, the foreach statement or lastly creating a for loop to iterate the array. If you need to modify only a single instance, or just a few, you will need to provide a condition to control the modification.

$plist.ACPI.DSDT.Patches.foreach{ 
    # modify `$_.Find` here
}

# or

$plist.ACPI.DSDT.Patches | ForEach-Object { 
    # modify `$_.Find` here
}

# or

foreach ($patch in $plist.ACPI.DSDT.Patches) {
    # modify `$patch.Find` here
}

# or

for ($i = 0; $i -lt $plist.ACPI.DSDT.Patches.Length; $i ++ ) {
    # modify `$plist.ACPI.DSDT.Patches[$i].Find` here
}

from pwshreadxmlplist.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.