Help with topic in learn in 30 lunches book please

Welcome Forums General PowerShell Q&A Help with topic in learn in 30 lunches book please

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years ago.

  • Author
    Posts
  • #5491

    Member
    Points: 0
    Rank: Member

    by mikeyc at 2013-01-31 01:46:17

    Hi,

    I'm a bit stuck in one of the labs in the early chapters of the Learn Powershell in 30 lunches book.

    The question:

    Create a CliXML reference file for the services on your computer. Then, change
    the status of some non-essential service like BITS (stop it if it’s already started;
    start it if it’s stopped on your computer). Finally, use Diff to compare the reference
    CliXML file to the current state of your computer’s services. You’ll need to
    specify more than the Name property for the comparison—does the -property
    parameter of Diff accept multiple values? How would you specify those multiple
    values?

    My answer with lots of attempts and properties (which do support multiple values and seperated by a ',') is

    diff -ref (import-clixml ref.xml) -diff (gsv)

    but this fails to give an information and I'm struugling to determine which property to pull -property name doesn't add much more
    Thanks
    Mike

    by nohandle at 2013-01-31 06:19:10

    I don't own the book but I would answer like this:

    —does the -property
    parameter of Diff accept multiple values?

    Yes it accepts array of objects as input.
    (Get-Command Compare-Object | Select-Object -ExpandProperty parameters ).property.parameterType.name
    Object[]
    Or I can get the info from documentation using get-help -parameter

    How would you specify those multiple
    values?

    I would specify them as array of strings separated by the array operator -> ','.

    $refereceneObject = Import-Clixml -Path 'c:\Temp\services1.xml'
    $differenceObject = Import-Clixml -Path 'c:\Temp\services2.xml'

    Compare-Object -ReferenceObject $refereceneObject -DifferenceObject $differenceObject -Property ServiceName, status

    by mikeyc at 2013-02-01 04:54:02

    Thanks I'll give it a try

The topic ‘Help with topic in learn in 30 lunches book please’ is closed to new replies.