Powershell @{} Pipeline Error -



Powershell @{} Pipeline Error -

i have 2 custom powershell functions meant used like:

get-users | select loginname | get-userjobstatus -startdate 2013-02-19 -enddate 2013-02-21

when ran, receive error web service:

@{loginname=username} not found

which makes sense, because username that's passed web service function should username , not @{loginname=username}. how format correctly?

function global:get-backupjobstatus { [cmdletbinding()] param( [parameter( mandatory=$true, helpmessage='specific business relationship name.', parametersetname='loginname', valuefrompipeline=$true )] [system.string[]]$loginname = $null, [parameter( mandatory=$false, helpmessage='start date report.' )] [system.datetime]$startdate, [parameter( mandatory=$false, helpmessage='ending date report.' )] [system.datetime]$enddate ) begin { $tempxml = new-object system.xml.xmldocument write-output $startdate.tostring("yyyy-mm-dd") } process{ $tempxml.load("https://webservicecall/info.do?loginname="+$loginname+"&date="+$startdate.tostring("yyyy-mm-dd")) } end { write-output $tempxml.users.user } }

the problem function expecting string-object loginname input , sending pscustomobject(created select) property called loginname. prepare this, utilize select-object's -expandproperty parameter send value of loginnameinstead of objects property. this:

get-users | select -expandproperty loginname | get-userjobstatus -startdate 2013-02-19 -enddate 2013-02-21

powershell

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -