These are two different result request
All that access time stuff is from this…
$FilePath = ‘D:\temp\FileList.txt’
Get-ChildItem -Path $FilePath |
Get-Member |
Select-Object -Property Name
# Results
<#
Name
----
…
PSChildName
PSDrive
PSIsContainer
PSParentPath
PSPath
PSProvider
Attributes
CreationTime
CreationTimeUtc
Directory
DirectoryName
Exists
Extension
FullName
IsReadOnly
LastAccessTime
LastAccessTimeUtc
LastWriteTime
LastWriteTimeUtc
Length
Name
…
BaseName
VersionInfo
#>
… not this …
Get-Acl -Path $FilePath |
Get-Member |
Select-Object -Property Name
# Results
<#
Name
----
Access
CentralAccessPolicyId
CentralAccessPolicyName
Group
Owner
Path
Sddl
AccessRuleFactory
AddAccessRule
AddAuditRule
AuditRuleFactory
Equals
GetAccessRules
GetAuditRules
GetGroup
GetHashCode
GetOwner
GetSecurityDescriptorBinaryForm
GetSecurityDescriptorSddlForm
GetType
ModifyAccessRule
ModifyAuditRule
PurgeAccessRules
PurgeAuditRules
RemoveAccessRule
RemoveAccessRuleAll
RemoveAccessRuleSpecific
RemoveAuditRule
RemoveAuditRuleAll
RemoveAuditRuleSpecific
ResetAccessRule
SetAccessRule
SetAccessRuleProtection
SetAuditRule
SetAuditRuleProtection
SetGroup
SetOwner
SetSecurityDescriptorBinaryForm
SetSecurityDescriptorSddlForm
ToString
PSChildName
PSDrive
PSParentPath
PSPath
PSProvider
AccessRightType
AccessRuleType
AreAccessRulesCanonical
AreAccessRulesProtected
AreAuditRulesCanonical
AreAuditRulesProtected
AuditRuleType
MSDN
AccessToString
AuditToString
#>
Unless you explicitly combine these results in an object, you cannot do this…
<#
| select-object -Property Device, SName, Directory,
User, Control, Access, IsInherited, Date, PropagationFlags,
Description, InstallDate, Caption, LastUsed, CreateDate,
Description2, CreationTime
#>
Which is why you are most likely getting this…
‘D:\temp\FileList.txt’ |
ForEach{
Get-ChildItem -Path $PSItem
Get-Acl -Path $PSItem
} |
Select-Object -Property Directory, User, Control,
Access, IsInherited, Date, PropagationFlags,
Description, InstallDate, Caption,
LastUsed, CreateDate, Description2, CreationTime
# Results
<#
Directory : D:\temp
User :
Control :
Access :
IsInherited :
Date :
PropagationFlags :
Description :
InstallDate :
Caption :
LastUsed :
CreateDate :
Description2 :
CreationTime : 31-Jan-20 23:38:22
Directory :
User :
Control :
Access : {System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule}
IsInherited :
Date :
PropagationFlags :
Description :
InstallDate :
Caption :
LastUsed :
CreateDate :
Description2 :
CreationTime :
#>
Vs this…
Clear-Host
‘D:\temp\FileList.txt’ |
ForEach{
$ReportObject = [PSCustomObject]@{
FileObject = (
Get-ChildItem -Path $PSItem |
Select-Object -Property ‘'
)
AccessObject = (
Get-Acl -Path $PSitem |
Select-Object -Property '
’
)
}
}
$ReportObject.FileObject
<#
PSPath : Microsoft.PowerShell.Core\FileSystem::D:\temp\FileList.txt
PSParentPath : Microsoft.PowerShell.Core\FileSystem::D:\temp
PSChildName : FileList.txt
PSDrive : D
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
Mode : -a----
VersionInfo : File: D:\temp\FileList.txt
InternalName:
OriginalFilename:
FileVersion:
FileDescription:
Product:
ProductVersion:
Debug: False
Patched: False
PreRelease: False
PrivateBuild: False
SpecialBuild: False
Language:
BaseName : FileList
Target : {}
LinkType :
Name : FileList.txt
Length : 66
DirectoryName : D:\temp
Directory : D:\temp
IsReadOnly : False
Exists : True
FullName : D:\temp\FileList.txt
Extension : .txt
CreationTime : 31-Jan-20 23:38:22
CreationTimeUtc : 01-Feb-20 07:38:22
LastAccessTime : 01-Feb-20 00:22:46
LastAccessTimeUtc : 01-Feb-20 08:22:46
LastWriteTime : 01-Feb-20 00:22:46
LastWriteTimeUtc : 01-Feb-20 08:22:46
Attributes : Archive
#>
$ReportObject.AccessObject
<#
PSPath : Microsoft.PowerShell.Core\FileSystem::D:\temp\FileLis
t.txt
PSParentPath : Microsoft.PowerShell.Core\FileSystem::D:\temp
PSChildName : FileList.txt
PSDrive : D
PSProvider : Microsoft.PowerShell.Core\FileSystem
CentralAccessPolicyId :
CentralAccessPolicyName :
Path : Microsoft.PowerShell.Core\FileSystem::D:\temp\FileLis
t.txt
Owner : BUILTIN\Administrators
Group : Lab01\postanote
Access : {System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule}
Sddl : O:BAG:S-1-5-21-3258886415-1034932420-179337933-1002D:
(A;ID;FA;;;BA)(A;ID;FA;;;SY)(A;ID;0x1301bf;;;AU)(A;ID
;0x1200a9;;;BU)
AccessToString : BUILTIN\Administrators Allow FullControl
NT AUTHORITY\SYSTEM Allow FullControl
NT AUTHORITY\Authenticated Users Allow Modify,
Synchronize
BUILTIN\Users Allow ReadAndExecute, Synchronize
AuditToString :
AccessRightType : System.Security.AccessControl.FileSystemRights
AccessRuleType : System.Security.AccessControl.FileSystemAccessRule
AuditRuleType : System.Security.AccessControl.FileSystemAuditRule
AreAccessRulesProtected : False
AreAuditRulesProtected : False
AreAccessRulesCanonical : True
AreAuditRulesCanonical : True
#>
Of course, you’ll need to take what I show here and tweak it to meet your end result needs.
For example, directly combining the results of both commands.
Clear-Host
‘D:\temp\FileList.txt’ |
ForEach{
$FileObject = Get-ChildItem -Path $PSItem |
Select-Object -Property ‘'
$AccessObject = Get-Acl -Path $PSItem |
Select-Object -Property '
’
[PSCustomObject]@{
Directory = $FileObject.Directory
User = $AccessObject.Group
Access = $AccessObject.Access
Description = $FileObject.VersionINfo.FileDescription
CreationTime = $FileObject.CreationTime
CreationTimeUtc = $FileObject.CreationTimeUtc
LastAccessTime = $FileObject.LastAccessTime
LastAccessTimeUtc = $FileObject.LastAccessTimeUtc
LastWriteTime = $FileObject.LastWriteTime
LastWriteTimeUtc = $FileObject.LastWriteTimeUtc
}
}
# Results
<#
Directory : D:\temp
User : Lab01\postanote
Access : {System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule,
System.Security.AccessControl.FileSystemAccessRule}
Description :
CreationTime : 31-Jan-20 23:38:22
CreationTimeUtc : 01-Feb-20 07:38:22
LastAccessTime : 01-Feb-20 00:22:46
LastAccessTimeUtc : 01-Feb-20 08:22:46
LastWriteTime : 01-Feb-20 00:22:46
LastWriteTimeUtc : 01-Feb-20 08:22:46
#>
The last point is, as you can see above, you are calling a lot of properties that are not in the commands you are passing in. Assuming you are showing all your code for this use case here.