我已经尽力了,我感到十分困惑。我刚接触 PowerShell,也试过了网上能找到的所有相关内容。我现在想做的是将哈希表中的数组打印到文件中,但是每个数组值后面都会出现可恶的省略号。以下是我最好的尝试结果。
现在,经过所有这些操作,我仍然得到以下结果:
日期_发送 PSV类型 --------- --------- 20091201 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091202 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091203 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091204 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091207 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091208 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091209 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091210 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091211 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091214 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091215 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...}
请教一位更懂PowerShell的人告诉我我缺少了什么。如何消除末尾的省略号并写出数组的所有成员,无论有多少个?我必须通过构建一个大字符串缓冲区并将其输出到文件中来实现一些非正式的解决方案吗? 还是有更好的方法来解决这个问题?
谢谢。
# Update output buffer size to prevent clipping in output window.
if( $Host -and $Host.UI -and $Host.UI.RawUI )
{
$rawUI = $Host.UI.RawUI
$oldSize = $rawUI.BufferSize
$typeName = $oldSize.GetType( ).FullName
$newSize = New-Object $typeName (1000, $oldSize.Height)
$rawUI.BufferSize = $newSize
}
# Suposedly to allow enumeration in formatting to be unlimited
$formatenumerationlimit = -1
$Dir = get-childitem c:\SomeFolderWithFiles -recurse
$List = $Dir | where {$_.extension -eq ".hash"} | where-object {$_ -ne $null}
$lookupTable = @{}
Foreach ($element in $List)
{
#Get the type of file from filename
$PSV_Type = $element.Name.Substring(0, $element.Name.indexOf("."))
#Get the date sent from filename
$Date_Sent = $element.Name.Substring($element.Name.length - 20,8)
#Populate hashTable
.....
}
$columns = @{Expression={$_.Name};Label="Date_Sent";width=12}, @{Expression={$_.Value};Label="PSV_Types";width=1000}
$lookupTable.GetEnumerator() | Sort-Object Name | Format-Table $columns | out-file C:\hashFiles.txt -width 1012
现在,经过所有这些操作,我仍然得到以下结果:
日期_发送 PSV类型 --------- --------- 20091201 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091202 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091203 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091204 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091207 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091208 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091209 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091210 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091211 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091214 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...} 20091215 {31,ALLOCATIONS,AUDIT_TRAIL,BOOKS ...}
请教一位更懂PowerShell的人告诉我我缺少了什么。如何消除末尾的省略号并写出数组的所有成员,无论有多少个?我必须通过构建一个大字符串缓冲区并将其输出到文件中来实现一些非正式的解决方案吗? 还是有更好的方法来解决这个问题?
谢谢。