Hello,
I am a little bit stuck with a script and I am wondering if someone here could be so kind to help me out.
What I am trying to achieve is to parse the output from a external command which currently I have it save in a $custom variable into a pscustomboject.
PS C:\> $custom
Record #1
deviceName: BRCTX021
serverName: CHCTXPVS001
Record #2
deviceName: BRCTX035
serverName: CHCTXPVS001
.....
I would like to create a custom Psobject with the Name Record, Devicename and ServerName.
What I was trying was something like that.
What I was trying was something like that.
foreach ($propertyin$custom) {
$record=if ($property-like"record*") { $property.trim() }
$Devicename=if ($property-like"devic*") {$property.split(":")[1].trim()}
$output=New-object Psobject -property @{
Record =$record
Devicename =$Devicename
}
$output | select Record,Devicename
}
$record=if ($property-like"record*") { $property.trim() }
$Devicename=if ($property-like"devic*") {$property.split(":")[1].trim()}
$output=New-object Psobject -property @{
Record =$record
Devicename =$Devicename
}
$output | select Record,Devicename
}
my $ouput variable is empty
Thanks for your help, very much appreciated.
REgards,
Jacobo.