@יוסי-מחשבים זה הפלט -
C:\Users\2>$printerName = "Microsoft Print to PDF"
'$printerName' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>$files = "C:\Users\2\Desktop\חבורות"
'$files' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2>$word = New-Object -ComObject Word.Application
'$word' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>$word.Visible = $false
'$word.Visible' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2>foreach ($file in $files) {
'foreach' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2> $doc = $word.Documents.Open($file)
'$doc' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2> $pdfPath = [System.IO.Path]::ChangeExtension($file, "pdf")
'$pdfPath' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2> # מגדיר את המדפסת
'#' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2> $word.ActivePrinter = $printerName
'$word.ActivePrinter' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2> # הדפסה למדפסת PDF
'#' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2> $doc.PrintOut()
'$doc.PrintOut' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2> Start-Sleep -Seconds 2 # השהייה קטנה כדי למנוע התנגשויות
'Start-Sleep' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2> $doc.Close()
'$doc.Close' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>}
'}' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\2>
C:\Users\2>$word.Quit()
לכאורה לא תקין, בגלל שבכל אנטר הוא מתחיל את הקוד מחדש. אני טועה?