per cambiamenti una tantum per colonne visualizzate, tubazioni per select
o Format-Table
è più facile. Se si desidera rendere questa modifica permanente, è necessario gestire i file di formato che governano il modo in cui PowerShell visualizza gli oggetti del filesystem.
La modifica del file di formato esistente (probabilmente a $env:SystemRoot\system32\WindowsPowershell\v1.0\FileSystem.format.ps1xml
) non è consigliata, poiché il file ha un blocco di firma nella parte inferiore. La modifica del contenuto del file invaliderà la firma, che può causare problemi.
Invece, è possibile definire il proprio file di formato che sovrascriverà quello predefinito. Salvare il file di seguito come FileFormat.format.ps1xml
e gestito
Update-FormatData -Prepend c:\FileFormat.format.ps1xml
Per impostazione predefinita, verrà mostrato CreationTime
, non LastWriteTime
.
contenuto del file Format (copiato dal file di formato reale, appena cambiato i bit rilevanti):
<Configuration>
<SelectionSets>
<SelectionSet>
<Name>FileSystemTypes</Name>
<Types>
<TypeName>System.IO.DirectoryInfo</TypeName>
<TypeName>System.IO.FileInfo</TypeName>
</Types>
</SelectionSet>
</SelectionSets>
<ViewDefinitions>
<View>
<Name>children</Name>
<ViewSelectedBy>
<SelectionSetName>FileSystemTypes</SelectionSetName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>PSParentPath</PropertyName>
<CustomControlName>FileSystemTypes-GroupingFormat</CustomControlName>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Mode</Label>
<Width>7</Width>
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>CreationTime</Label>
<Width>25</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Length</Label>
<Width>10</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<Wrap/>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Mode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
[String]::Format("{0,10} {1,8}", $_.CreationTime.ToString("d"), $_.CreationTime.ToString("t"))
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Length</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
ha sbagliate a scrivere CreationTime o hai fatto significa davvero sostituire LastWriteTime con CreatingTime? – dugas
sì, penso di averlo fatto – silla