Ich versuche, das PowerShell-Skript unten mit PSv5 zu verwenden, um einige manuelle Prozesse zu automatisieren, aber es schlägt fehl und ich kann nicht herausfinden, warum. Wenn ich versuche, es in ISE zu debuggen, ich erhalte, ist der folgende Fehler und keine Ausgabedatei erzeugt:PowerShell-Skript schlägt fehl
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:15 char:53
+ $HeaderLine, ${$DestinationFile} = Get-Content -Path <<<< $SourceFile.FullName
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand
# BEGIN SCRIPT
#
# Collect all the files in the directory
$SoureFiles = Get-ChildItem -Path 'C:\raw' -Filter '*.txt'
# Create the destination file
$DestinationFile = (New-Item -Path 'c:\done' `
-Name ('CombinedSources-' + (Get-Date -Format 'ddMMMyyyy') + '.txt') `
-ItemType File -Force).FullName
$DestinationFile
# Loop source, files, remove header line, append to the destination file
ForEach ($SourceFile in $SoureFiles)
{
$HeaderLine, ${$DestinationFile} = Get-Content -Path $SourceFile.FullName
${$DestinationFile}`
| Out-File -FilePath $DestinationFile -Append
}
# Sort the Destination file content and replace with sorted unique lines
(Get-Content -Path $DestinationFile `
| Sort-Object { [string]$_.split(',')[1,2] }) `
| Get-Unique `
| Out-File -FilePath $DestinationFile -Force
#
#END SCRIPT
Wo scheitert es? Was hast du probiert? – Nick
Wie scheitert es? Können Sie die Ausgabe posten? – PrestonM
Bitte [bearbeiten Sie Ihre Frage] (https://stackoverflow.com/posts/44395657/edit), um die tatsächliche Fehlermeldung, die Sie erhalten, einzuschließen. – sodawillow