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 :


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.

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

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 `
		@{n='Probes'; e={($_.Probes | ForEach-Object {$_.ToString()}) -join ', '}},

Open in new window

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

Microsoft.Azure.Commands.Network.Models.PSProbe, Microsoft.Azure.Commands.Network.Models.PSProbe
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

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).
Kelly GarciaSenior Systems AdministratorAuthor Commented:
is there any way of doing this, as this export may require import for processing therefore makes it complicated
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.

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

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.
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

From novice to tech pro — start learning today.