Я динамически создаю простую веб-страницу.По какой-то причине я получаю сообщение об ошибке выше.
Это мой код.
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value;
if($Invocation.PSScriptRoot)
{
$Invocation.PSScriptRoot;
}
Elseif($Invocation.MyCommand.Path)
{
Split-Path $Invocation.MyCommand.Path
}
else
{
$Invocation.InvocationName.Substring(0,$Invocation.InvocationName.LastIndexOf("\"));
}
return $Invocation
}
################################## start here #########################################################################
#write before to html file
$filenameOut = "php_docs_newest.html"
$filenameBegin = "before.txt"
$filenameAfter = "after.txt"
#get filenames from directories and put in group named for folder
#get current working dir
$cwd = Get-ScriptDirectory #(Get-Location).path #PSScriptRoot #(Get-Item -Path ".").FullName
$filenamePathOut = Join-Path $cwd $filenameOut
#beginning html content to file
$filenamePathBeginning = Join-Path $cwd $filenameBegin
Get-Content -Path $filenamePathBeginning | Set-Content -Path $filenamePathOut #this is where I get subject error message
Когда я смотрю на $cwd
, это C:\Users\me\Documents\subdir
, что выглядит хорошо.
Кроме того, $filenamePathOut
показывает C:\Users\me\Documents\subdir\php_docs_newest.html
, что тоже хорошо.
Я не уверен, почему я получаю сообщение об ошибке, в котором используется H:\System.Management.Automation.InvocationInfo
.Как это исправить?Требуется ли приведение или преобразование?
Я пытался использовать Set-Content для совместного чтения / записи.
После того, как этот предварительный html был записан на выходфайл, я напишу динамический список файлов, прочитанных из подкаталога.