因此,这可能是菜鸟错误。众所周知,我正在尝试为具有“权限被拒绝”的目录打印NetworkPath
和Permissions
。我知道问题出在我的管道上
$AccessPresentation |
Select-Object -Property NetworkPath, Permissions |
export-csv -NoTypeInformation -Path $AccessDeniedFolders
具体地说,在我看来,我与Select-Object
在一起,但是我不知道自己做错了什么。运行代码,然后打开.csv时,它所做的只是提供NetworkPath
和Permissions
,并提供值System.Objects[]
。我做错了什么?
$AccessDeniedFolders = "c:\users\john.smith\desktop\AccessDeniedFolders.csv"
$AccessPresentation = @()
$AccessDeniedError = @()
$Properties = @{}
$folders = Get-ChildItem -Path Z:\ -recurse -ea silentlycontinue -ErrorVariable +AccessDeniedError | ?{$_.PSIsContainer} | Out-Null
$AccessDeniedError | select -expand categoryinfo
$Properties = @{'NetworkPath'=$AccessDeniedError.TargetObject;'Permissions'=$AccessDeniedError.CategoryInfo.Category}
$AccessPresentation += New-Object -TypeName PSObject -Property $Properties
$AccessPresentation | Select-Object -Property NetworkPath, Permissions | export-csv -NoTypeInformation -Path $AccessDeniedFolders