To be honest... I think your best bet is using custom objects. I have a couple
of blog post here
http://bsonposh.com/page/2?s=Custom+Object specifically
http://bsonposh.com/archives/221
But to answer your question... You can use Add-Member to add a property.
$object | add-member -membertype noteproperty -name HostNam -value $name
Brandon Shell
---------------
Blog:
http://www.bsonposh.com/
PSH Scripts Project:
www.codeplex.com/psobject
R> I've scoured the net and haven't been able to figure out how to do
R> this or if it's even possible.
R>
R> What I'm trying to do is create some modular scripts I can pipeline
R> to each
R> other. For example:
R> GetADObj.ps1 will perform an AD query.
R> GetEvents.ps1 will get and filter the event log configs from a list
R> of AD
R> objects piped in.
R> ExportXLS.ps1 will export a list of fields to an excell document.
R> So I can run the scripts like so GetADObj | GetEvents | ExportXLS (I
R> know the syntax here is not quite right. The reall syntax will have
R> paths and paramters.)
R>
R> With some help (thanks Brandon) I have the GetADObj script passing a
R> list of objects to the pipeline and the GetEvents scrip recieves the
R> pipeline and is able to access the event log configs on AD machine
R> objects pipeline. I think I've managed replaced the incoming AD
R> objects with Event Viewer Config objects, I haven't figured out how
R> to include the hostname from the AD object with the outgoing objects.
R>
R> Is it possible to add information to the pipeline like the hostname
R> the event log configs came from?
R>
R> Here is the bare bones GetEvents .ps1 I have so far...
R>
R> process
R> {
R> # get the name of the host from the incoming AD object pipeline
R> $strHostname = [string]$_.properties.name
R> # this portion dispalys to the screen the information I'd like to
R> pass to
R> the pipeline
R> write-host $strHostname -ForegroundColor Green
R> $a = [System.Diagnostics.Eventlog]::GetEventLogs($strHostname)
R> $a
R> # Send the eventlog info and the hostname out to the pipeline
R> $_ = $a,$strHostname
R> }