Help with topic in learn in 30 lunches book please
by mikeyc at 2013-01-31 01:46:17
I'm a bit stuck in one of the labs in the early chapters of the Learn Powershell in 30 lunches book.
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
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
by nohandle at 2013-01-31 06:19:10
I don't own the book but I would answer like this:
[quote="mikeyc"]â€”does the -property
parameter of Diff accept multiple values?[/quote]
Yes it accepts array of objects as input.
(Get-Command Compare-Object | Select-Object -ExpandProperty parameters ).property.parameterType.name
Or I can get the info from documentation using get-help -parameter [quote="mikeyc"]How would you specify those multiple
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
You must be logged in to reply to this topic.