I am trying to gather the acl for each of our mail-in databases. I have found a way to do so with one database, but for some reason when I try to expand the process to use a loop to grab them all, I end up failing.
The working part goes as follows:
$Notes = New-Object -ComObject Lotus.NotesSession
$Notes.Initialize()
$server = “servername”
$folder = “mail-in”
$database = “filename.nsf”
$NotesDabase = $Notes.GetDatabase($server,“folder$datbase”)
$acl = $notesdatabase.acl
$firstentry = $acl.GetfirstEntry()
While ($firstentry -ne $null)
{
Write-Output $firstentry.name
$nextentry = $$acl.getnextentry($firstentry)
$firstentry = $nextentry
}
It stops working when I try to use a for loop to handle a number of databases. It seems as though the acl property is lost in the process somehow, so that when it looks for it, it comes up with a null value and failes.
You’ve run into one of the most fun PowerShell gotchas.
$Files = $List | select -property name
$Files is not a list of filenames as this point. It is a collection of objects, each of which has a Name property only. You probably wanted to do this:
$Files = $List | select -expandproperty name
Now, $Files is indeed just a list of strings. Although it could also include folders, since your Get-ChildItem didn’t restrict the results to only file objects. Use the -File parameter to do that.
See https://powershell.org/kb/properties-vs-values/ for a deeper explanation. As a debugging note, this happened because $F didn’t contain what you thought it did. I’d have added some code to output the contents of my variables, or set a breakpoint inside the loop and manually inspected the contents of the variables, to confirm that they continued what I thought they did.
In your case, “$folder$F” probably evaluated to something like “folder name{Selected.System.FileInfo}” or something, which I bet isn’t what you thought it would.