Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

No Clue what I'm doing

$
0
0

I was given the script below and told to change the file name and that's it.  The guy that sent it is on vacation and I need to figure out how to run it.   I copied everything it shows within PS.

PS C:\Windows> $missingfiles = $missingfilelist.filepath

$missingfiles|ForEach-Object{

if (Test-Path -Path "$_")
{
write-host -ForegroundColor Yellow "This file exists [ $_ ]"
$filepresence = "File Exists"

}
else
{
write-warning "this file doesn't exist [ $_ ]"
$filepresence = "File Doesn't Exist"
}

$fileentry = $filebase | Select-Object *

$fileentry.FilePath = $_;
$fileentry.Presence = $filepresence;
[Void]$fileresults.Add($fileentry);

}


$fileresults| export-csv C:\Users\rhead\Desktop\HEART_List_of_all_missing_images-.csv -NoTypeInformation -Append
Test-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At line:5 char:20
+ if (Test-Path -Path <<<<  "$_")
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
 
Export-Csv : A parameter cannot be found that matches parameter name 'Append'.
At line:26 char:113
+ $fileresults| export-csv C:\Users\rhead\Desktop\HEART_List_of_all_missing_images-.csv -NoTypeInformation -Append <<<<
    + CategoryInfo          : InvalidArgument: (:) [Export-Csv], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ExportCsvCommand


Viewing all articles
Browse latest Browse all 6937

Trending Articles