title: How to return a Powershell Object Property Value to an excel Cell
body: <p>So I am running a Powershell script that will return the ALL the Users and their Access Permissions for all Shared Folders with in a Specified Folder. My problem is, I am trying to get Powershell to dump the info directly into an open excel file. So far the script runs outputs to a CSV file with the correct info, but when when I try to get it to dump into the excel it doesn't work. his is because I can not figure out how to set the cell value to the Object property value.</p>
  
  <p>Here is the Code</p>
  
  <pre><code>#Get Folder Permissions
  
  $xl = [Runtime.Interopservices.Marshal]::GetActiveObject('Excel.Application')
  $targetWBpath = 'C:\&lt;Path&gt;\test_dump.xlsx'
  $targetWbName = Split-Path $targetWbpath -Leaf
  $targetWB = $xl.Workbooks.Item($targetWBName)
  $targetWS = $targetWB.Sheets.Item('Test_1')
  $cells = $targetWS.Cells
  $row = 1
  $col = 1
  
  "User","Folder","Access" | foreach {
      $cells.item($row,$col)=$_
      $cells.item($row,$col).font.bold=$True
      $col++
  }
  
  $row = 2
  
  Get-childitem "&lt;Path to Target Folder&gt;" -recurse | where{$_.psiscontainer} |
  
  Get-Acl | % {
  
  $path = $_.Path
  
  $_.Access | % {
  
  New-Object PSObject -Property @{
  
  Folder = $path.Replace("Microsoft.PowerShell.Core\FileSystem::","")
  
  Access = $_.FileSystemRights
  
  User = $_.IdentityReference
  
  } 
  
  $col = 1
  $cells.item($row,$col) = User &lt;How do I get the Property Value Here for the User property&gt;
  $col++
  $cells.item($row,$col) = Folder &lt;How do I get the Property Value Here for the Folder property&gt;
  $col++
  $cells.item($row,$col) = Access &lt;How do I get the Property Value Here for the Access property&gt;
  $col++
  $row++
  }
  }
  
  $xl.Quit()
  [System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl)
  </code></pre>
  
  <p>It would be nice if I could figure out how to do a Foreach loop to retrieve the property values , but I couldn't figure that out either. FYI this is my first Powershell script so I apologize if this is a not so challenging question. 
  Overall Goal is to call this from a VBA script and have the output placed in the Workbook the script is running from.</p>
  
  <p>Thank you for your help, JD</p>