(get-acl D:\dept-home).Access |select -expandproperty identityreference
Just enclose the whole expression in ( ... ) -join ','do you ever see any blanks or duplicates?
PS C:\Temp> (get-acl T:\Company\Test\).Access |select -expandproperty identityreference |% {$_.value.split('\')[1]}
Example_SecGroup_TSRemoteUsers
BackupOperator
SYSTEM
Domain Admins
Domain Users
Administrators
Users
PS C:\Temp> ((get-acl T:\Company\Test\).Access |select -expandproperty identityreference |% {$_.value.split('\')[1]}) -join ','
Example_SecGroup_TSRemoteUsers,BackupOperator,,SYSTEM,Domain Admins,Domain Users,Administrators,Users
I cannot find a reason for IdentityReference (or its split) being empty unless the ACL itself is empty, or the split being empty, which means the ACL is not following the namespace\object format?
As I see it, the whole expression, removing dups, can be significantly simplified (changing much of the original command):
Open in new window
This assumes IdentityReference is never empty.