Confused on some questions from a book about pipeline. I think I understand pipeline now but the questions dont make sense.


below questions powershell book using learn , confused question.

------------------------------------------------------

in exercise, goal determine how pipeline works (or doesn’t in cases). goal not run full commands, use get-help , get-member determine if work.

.

task 1

.

determine how object (or won’t) passed next command, either using byvalue or bypropertyname, , parameter making possible.  

.

get-service | select-object -property name  

.

task 2

.

determine how object (or won’t) passed next command, either using byvalue or bypropertyname, , parameter making possible.

get-service | format-table -property name

.

helmick, jason; robbins, mike f. (2015-01-28). windows powershell tfm (kindle locations 1816-1824). sapien press. kindle edition.

.

------------------------------------------------------

.

now watched video series on don jones read , studied in book.  not confused taught.

.

they taught understanding pipeline , how data sent , received can better know can , cannot use.

.

"how objects passed:

.

when object passed receiving cmdlet, object must bound parameter can receive (or grab) object. think moment. cmdlet receiving object attaches object 1 of parameters. once attached, receiving cmdlet can perform action on object."

.

to show basic ways done , how tell:

.

"there 2 methods of matching objects sending cmdlet across pipeline receiving cmdlet’s parameters, byvalue , bypropertyname. byvalue first way cmdlet try , it’s preferred method. if fails, cmdlet try bypropertyname. if fails, well… that. on next few pages, let’s see how each of these works."

.

helmick, jason; robbins, mike f. (2015-01-28). windows powershell tfm (kindle locations 1614-1617). sapien press. kindle edition.

.

the third way using parenthesis , -expandproperty parameter that's not discussed here , understand well.

.

to understand how byvalue works need know last part of typename 

if match both object being sent , parameter receiving can use byvalue. if not have move on bypropertyname works simple like.  name needs same.  (note have understand what's going on logically in regards this)

.

they taught tools find out above 3 strategies.  use get-member on sending, , use get-help -name cmdlet on receiving.

.

their first task asks select-object not seem go along taught byvalue, , bypropertyname had no parameters matched talked above.   in fact had 1 parameter accepted pipeline , "-inputobject" of type psobject , accept pipeline input of (byvalue).  not match type servicecontroller of object being sent.

.

however, stated: "you can pipe object select-object"

.

so after messing hours reading , reading chapter on again let go thinking on thinking it, , took above statement literally.

.

so moved on there , next question odd well, , yes know make these questions have study , go on material on , over, questions made way reason once again stuck not seem in same direction taught.

.

i go @ -full -format-table , check out parameters , once again trying determine how object (or won’t) passed next command, either using byvalue or bypropertyname, , parameter making possible.  

.

once again there 1 parameter accepts pipeline input pretty identical in select-object byvalue , of type psobject.  no other parameter accepts input pipeline.

.

however has message similar select-object:

.

"you can pipe object format-table"

.

both messages on down page , under inputs right before examples.

.

so on thinking this? need take things literally.  getting thrown off because 1 never mentioned psobject , maybe has  no importance here, examples when them up keep saying take object.  

.

sometimes take easy , not want accept because think want me figure out harder, on think it, maybe doing now?

.

i answer had byvalue that's thing accept pipe didn't have same type, , there clause @ end said accepts object?  kind of gets away answer looking right?

.

look @ example first time 1 don't seem bad , show 1 show understanding stuff first 2 questions throwing me off.

.

-----------------------------------

task 3

.

determine how object (or won’t) passed next command, either using byvalue or bypropertyname, , parameter making possible. following csv has column name names , list of computer names.  

.

import-csv c:\ servers.csv | get-service -name bits

.

helmick, jason; robbins, mike f. (2015-01-28). windows powershell tfm (kindle locations 1825-1829). sapien press. kindle edition.

.

-----------------------------

on above of type pscustomobject , name native type string. pull get-help -full get-service , @ parameters.

.

  1. -computername accepts pipeline bypropertyname of type string (this 1 use if possible)
  2. -inputobject accepts pipeline byvalue of type servicecontroller.
  3. -name accepts pipeline byvalue, , bypropertyname of type string
  4. .

under inputs (i'm starting see cool shortcut) says accepts type servicecontroller don't think byvalue accepted csv of type pscustomeobject  have different type.  however, bypropertyname match 100%.

.

this 1 give me error. going see -name , going first use byvalue if did not work next use bypropertyname.    going try use -name.

.

however more important answer line of code or whatever call line of powershell stuff(a script?) not make logical sense.  taking data , trying pipe into  command giving after not need piped info.  regardless not work.

.

i did figure out how make work on own without using google , didn't have commands , stuff , did have learned reading book , watching video earlier today.  in past never able trouble shoot or come own line of powershell code repurpose other peoples code found online though stuff basic stuff kind of cool able put things first time in life since coming across powershell.

.

anyway here came with:

.

import-csv.\servers.csv|select-object-property@{n='computername';e={$_.name}} |get-service-name*

.

----------

.

two cool things tips did on learned book , video.

.

1. knowing when got error not find service service name dc2 sending name -name service did not want.  in order fix manually specified -name parameter taken off list pipeline input. (learned don jones video).

.

2. how create custom property

.

get-service : cannot find service service name '@{computername=dc2}'.

.

anyway learning if simple stuff right now, first 2 questions threw me off.  or input on those.

.





larry,

your statement "inputobject" wrong , misleading. applies using service controller object.  pipeline can fed kind of object including csv object.  exact thing confusing op. increasing confusion.

i can send pipeline.  "inputobject" can take 1 kind of object.  "inputobject" not pipeline. aparameter can passed so:

get-service -inputobject $aservicecontroller


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS