Object properties and Variables

Viewed 39

What I am working with is this (Exchange online powershell):

get-publicfolder -Identity "\TestFolder" -Recurse|Where{$_.mailenabled -eq "true"}

So what I am interested in is getting the parentpath and name properties from that. How do I assign that to a variable so parentpath and name are on the same line Right now if I do

$myvar = $MailEnabledFolder.parentpath,$MailEnabledFolder.name

Then the variable is built like:

  • \TestFolder
  • \TestFolder\Test3
  • \TestFolder\Test3
  • Info
  • Processing
  • QA

I want it to be

  • \TestFolder\Info
  • \TestFolder\Test3\Processing
  • \TestFolder\Test3\QA

Thank you

1 Answers

Your $MailEnabledFolder.parentpath and $MailEnabledFolder.name values are apparently arrays of values, so you must process them in pairs:

$array1 = $MailEnabledFolder.parentpath
$array2 = $MailEnabledFolder.name

foreach ($i in 0..($array1.Count-1)) {
  Join-Path $array1[$i] $array2[$i]
}
Related