Expand property doesnt work in pscustomeobject

i have the script below however the expand property doesn't work,

$Subs = Get-AzureRmSubscription

$arr = @()

foreach($sub in $Subs){

   Set-AzureRmContext -SubscriptionObject $sub

	foreach ($lb in Get-AzureRmLoadBalancer) {
  
   	$Object= New-Object PSObject -Property @{

	Name = $lb.name
    ResourceGroupName = $lb.resourcegroupname
    Location = $lb.location
    Probes = $lb | select -ExpandProperty probes
    ProvisioningState = $lb.ProvisioningState
    ResourceGuid = $lb.ResourceGuid
    sku = $lb.sku
    tag = $lb.tag
    tagstable = $lb.tagstable
    BackendAddressPools = $lb.BackendAddressPools
    etag = $lb.etag
    FrontendIpConfigurations = $lb.FrontendIpConfigurations
    Id = $lb.Id
    LoadBalancingRules = $lb.LoadBalancingRules
     



	}

$arr += $Object

}#end $lbforeach
   
} #endsubforeach

Open in new window


it returns :

System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSProbe]

please help
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
The ExpandProperty works - you have the plain object that was in the "probes" property. The "issue" is that this object happens to be a list. What are you planning to do with the results? Process them further, or are you only interested in the string representation? If the latter, try
 
Probes = ($lb.probes | ForEach-Object {$_.ToString()}) -join ', '

Open in new window

0
oBdACommented:
On a side note: instead of creating a custom object like that, just use a Select-Object, since you want most of the original properties anyway:
$subs = Get-AzureRmSubscription
$arr = ForEach ($sub in $subs) {
	Set-AzureRmContext -SubscriptionObject $sub
	Get-AzureRmLoadBalancer | Select-Object -Property `
		Name,
		ResourceGroupName,
		Location,
		@{n='Probes'; e={($_.Probes | ForEach-Object {$_.ToString()}) -join ', '}},
		ProvisioningState,
		ResourceGuid,
		Sku,
		Tag,
		TagsTable,
		BackendAddressPools,
		ETag,
		FrontendIpConfigurations,
		Id,
		LoadBalancingRules
}

Open in new window

0
Kelly GarciaSenior Systems AdministratorAuthor Commented:
this dont work it gives me:

Microsoft.Azure.Commands.Network.Models.PSProbe, Microsoft.Azure.Commands.Network.Models.PSProbe
0
Hey MSSPs! What's your total cost of ownership?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

oBdACommented:
Well, what output do you require?
I can't test this; if the Probes result doesn't contain sensitive information, run
Get-AzureRmLoadBalancer | Select-Object -First 1 -ExpandProperty Probes | Export-CliXml -Path C:\Temp\Probes.xml

Open in new window

This will create a serialized representation of the object that can be analyzed.
Then use the "Attach File" link below to attach the Probes.xml file (depending on the size, it might need zipping first).
0
Kelly GarciaSenior Systems AdministratorAuthor Commented:
is there any way of doing this, as this export may require import for processing therefore makes it complicated
0
oBdACommented:
Either you analyze the Probes property yourself, diving in using Get-Member until you find the property or properties you want displayed/extracted, or you export a sample Probes object and upload it here like I described so that I can have a look at it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITguy565Commented:
@Kelly

oBdA is right, there isn't enough information to be able to assist with this question. We need to know the content in the spreadsheet you are importing. If it is confidential, then it is going to be difficult to assist with this question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.