# 필요한 PowerPoint 어셈블리를 추가합니다. Add-type -AssemblyName office -ErrorAction SilentlyContinue Add-Type -AssemblyName microsoft.office.interop.powerpoint -ErrorAction SilentlyContinue # 파워포인트를 시작합니다. $pptx = new-object -com powerpoint.application #$pptx.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue # 파워포인트 파일이 있는 위치(폴더)를 설정합니다. $filePath=Read-Host -Prompt '파워포인트 파일이 있는 폴더 경로를 입력하세요.(예, "C:\Test\")' $filePath=$filePath -replace '"','' # 저정한 위치(폴더)의 파워포인트 파일을 하나씩 처리 합니다. Foreach($inFile in $(ls $filePath -Filter "*.pptx")){ Set-ItemProperty ($filePath + $inFile) -name IsReadOnly -value $false $filename = Split-Path $inFile -leaf $file = $filename.Split(".")[0] $outFile = $filePath + $file + ".pdf" # 파워포인트 파일을 오픈합니다. $slides = $pptx.Presentations.Open($filePath + $inFile) # PDF로 저장합니다. $inMsg= $filePath + $file + ".pdf 생성중" Write-Host -Message $inMsg $saveOption= [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF $slides.SaveAs($outFile,$saveOption) # 오픈된 파워포인트 파일을 종료합니다. $slides.Close(); $outMsg=$filePath + $file + ".pdf 생성 완료!" Write-Host $outMsg } #정리: 파워포인트 실행 종료 및 가비지 컬렉션 수행 $pptx.quit(); $pptx = $null [gc]::Collect(); [gc]::WaitForPendingFinalizers();