🍅
if ($sourceFile.length -ne 0) {Как быть, если у
if((Split-Path $sourceFile -Extension) -eq '.pst'){
Write-Host('Parent is PST') -ForegroundColor Cyan
$toFolder = $sourceFile.replace('.pst','\');
} elseif ((Split-Path -Path (Split-Path -Path $sourceFile -Parent) -Extension) -eq '.msg') {
Write-Host('Parent is MSG') -ForegroundColor Cyan
$toFolder = Split-Path(Split-Path -Path $sourceFile -Parent) -Parent;
} elseif ((Split-Path -Path $sourceFile -Parent) -ne '') {
Write-Host('Parent is folder') -ForegroundColor Cyan
$toFolder = Split-Path -Path $sourceFile -Parent;
} else {
Write-Host('Root element') -ForegroundColor Cyan
$toFolder = ".\"
}
}
$SourceFile.msg
нет родителя? Предсказуемо выпадает в ошибку на второй веткеCannot bind argument to parameter 'Path' because it is an empty string.