I am creating a script that looks through our WebApp and gets all Site Collections, Sub-Sites and list all the documents with certain pieces of information regarding each item. I have to retrieve items within the folders of each Library which lead me to use a recursive method. However when I use the method I am unsure of how to return the ID of the item (Not GUID). So far anything I have tried has returned a null value. The method I am using is shown below:
Function GetFiles($folder)
{
Write-Host "+"$folder.Name
foreach($file in $folder.Files)
{
Write-Host "`t" $file.Name
}
# Use recursion to loop through all subfolders.
foreach ($subFolder in $folder.SubFolders)
{
Write-Host "`t" -NoNewline
GetFiles($Subfolder)
}
}
If anyone would know how to return the ID of the file that would great. Thanks in advance.