2011-10-14 19 views
6

Per esempio, considerare le seguenti console trascrizione:Come rendere PowerShell meno dettagliato sugli errori?

PS C:\dev\windows> rmdir -Recurse .\bin 
Remove-Item : Cannot remove item C:\dev\windows\bin\DotNet\Debug\Implementation\Common.DTO.XML: Access to the path 'Common.DTO.XML' is denied. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : PermissionDenied: (Common.DTO.XML:FileInfo) [Remove-Item], UnauthorizedAccessException 
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand 
Remove-Item : Directory C:\dev\windows\bin\DotNet\Debug\Implementation cannot be removed because it is not empty. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : WriteError: (Implementation:DirectoryInfo) [Remove-Item], IOException 
    + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand 

Remove-Item : Cannot remove item C:\dev\windows\bin\DotNet\Debug\Shunra.Common.Contract.XML: Access to the path 'Shunra.Common.Contract.XML' is denied. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : PermissionDenied: (Shunra.Common.Contract.XML:FileInfo) [Remove-Item], UnauthorizedAccessException 
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand 
Remove-Item : Cannot remove item C:\dev\windows\bin\DotNet\Debug\Shunra.Common.XML: Access to the path 'Shunra.Common.XML' is denied. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : PermissionDenied: (Shunra.Common.XML:FileInfo) [Remove-Item], UnauthorizedAccessException 
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand 
Remove-Item : Directory C:\dev\windows\bin\DotNet\Debug cannot be removed because it is not empty. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : WriteError: (Debug:DirectoryInfo) [Remove-Item], IOException 
    + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand 

Remove-Item : Directory C:\dev\windows\bin\DotNet cannot be removed because it is not empty. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : WriteError: (DotNet:DirectoryInfo) [Remove-Item], IOException 
    + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand 

Remove-Item : Directory C:\dev\windows\bin cannot be removed because it is not empty. 
At line:1 char:6 
+ rmdir <<<< -Recurse .\bin 
    + CategoryInfo   : WriteError: (C:\dev\windows\bin:DirectoryInfo) [Remove-Item], IOException 
    + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand 

PS C:\dev\windows> 

Ora confrontate con il guscio ordinaria (cmd.exe):

C:\dev\windows>rmdir /s/q bin 
bin\DotNet\Debug\IMPLEM~1\Common.DTO.XML - Access is denied. 
bin\DotNet\Debug\Shunra.Common.Contract.XML - Access is denied. 
bin\DotNet\Debug\Shunra.Common.XML - Access is denied. 

C:\dev\windows> 

La differenza è evidente e mi piace la laconicità del cmd. exe molto più della verbosità del powershell.

Posso avere la stessa laconicità in PowerShell? Se non per tutti i comandi allora forse solo per l'elemento Rimuovi, che uso spesso?

risposta

6

Il risultato più vicino che è possibile ottenere è la modifica del valore $ ErrorView a "CategoryView". Un altro modo è creare la tua vista.

+0

"CategoryView" è abbastanza buono per me, grazie. – mark

+3

Ecco alcuni materiali di partenza per la risposta di Shay: http://blogs.msdn.com/b/powershell/archive/2006/06/21/641010.aspx – halr9000

+0

@ halr9000 - grazie per le informazioni. Se lo organizzi come risposta, sarò felice di riconoscerti per questo. – mark

Problemi correlati