Skip to content

Instantly share code, notes, and snippets.

@whtsky
Created December 13, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whtsky/b0a71c1114636618a9d39c3a6aee947d to your computer and use it in GitHub Desktop.
Save whtsky/b0a71c1114636618a9d39c3a6aee947d to your computer and use it in GitHub Desktop.
Get-ChildItem -Path 'D:\PATH' -Filter *pptx -Recurse |
ForEach-Object -Begin {
$null = Add-Type -AssemblyName Microsoft.Office.Interop.powerpoint
$SaveOption = [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
$PowerPoint = New-Object -ComObject "PowerPoint.Application"
} -Process {
$Presentation = $PowerPoint.Presentations.Open($_.FullName)
$PdfNewName = $_.FullName -replace '\.pptx$','.pdf'
$presentation.SaveAs($PdfNewName,$SaveOption)
$presentation.close()
} -end{
$powerpoint.quit()
Stop-Process -name POWERPNT -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment