top of page
  • Writer's pictureRm

Driving can get pretty interesting in PUBG

0 views0 comments
  • Writer's pictureRm

I had a recent project at work which I was asked to find a better way to convert PDFs to TIFF (or TIF) in a batch without having to use Adobe Pro as Adobe Pro only runs on 32bit and large maps with multiple pages will error out or just take forever. I came up with a solution by using GhostScript to conver the PDFs and PowerShell to tell GhostScript what and how to convert.


Requirements:


PowerShell Script:


$tool = 'C:\Program Files\gs\gs9.22\bin\gswin64c.exe' #the path to your Ghostscript program.


#ask the user if the DPI should be 600 instead of 300

Write-host "Would you like to convert to 600 DPI? Default: 300 DPI" -ForegroundColor Yellow

$Readhost = Read-Host " ( y / n ) "

Switch ($ReadHost)

{

Y {$DPI = "-r600"}

N {$DPI = "-r300"}

Default {}

}


#ask the user if this is a multi-page pdf so it can split the pages into seperate tiff or tif files

Write-host "Is this a mult-page pdf?" -ForegroundColor Yellow

$Readhost = Read-Host " ( y / n ) "

Switch ($ReadHost)

{

Y {$multi = "_p%04d"}

N {$multi = ""}

Default {}

}

#asks the user for the input folder of the PDFs

[string]$files_folder = Read-Host -Prompt 'What is the input location of the PDF Files? Example: C:\Temp'


#asks the user for the output folder of the PDFs

[string]$files_folder_output = Read-Host -Prompt 'What is the output location of the TIF Files? Example: C:\Temp'


#tests out the folder path to make sure its there

$testfolder = Get-Item $files_folder_output


#sets the folder path based on test

$files_folder_output = $testfolder.FullName


#find all the pdfs in that folder

$pdfs = get-childitem $files_folder | where {$_.Extension -match "pdf"}


# for each pdf in the pdf folder, replace the pdf extention to tiff or tif and then run ghostscript to convert that pdf to G4 fax encoding tiff.

foreach($pdf in $pdfs)

{


$TIF = $pdf.Name.replace('.pdf','').replace('.pdf','') + $multi + '.tiff' #note: you can change '.tiff' to '.tif' if you want the .tif extension instead

#sets the tiff output folder and name

$TIFoutput = $files_folder_output+"\"+$TIF

#if the tiff or tif already exist, then don't convert it

if(test-path $TIF)

{

"TIF file already exists " + $TIF

}

else

#converts the pdf

{

'Processing ' + $pdf.Name

$param = "-sOutputFile=$TIFoutput"

& $tool -q -dNOPAUSE -sDEVICE=tiffg4 $DPI -dGraphicsAlphaBits=2 $param $pdf.FullName -c quit

#note: you can change tiffg4 (G4 fax encoding) to the encoding options listed in https://www.ghostscript.com/doc/9.21/Devices.htm

}

}




23 views0 comments

Requirements:Active Directory Module for Windows Powershell


Code:

Search-ADAccount -LockedOut | Where {$_.UserPrincipalName -like "*microsoft.com*" -and $_.LastLogonDate -gt (Get-Date).AddDays(-30)} | Where {$_.Enabled -eq "True"} | Export-Csv -Path C:\Users\$env:USERNAME\desktop\locked.csv


note: change microsoft.com to your company domain


This line of code will search your active directory accounts for all Locked users where their email domain name matches the listed email domain, the user's last logon date is within the last 30 days and where the account is enabled, then it export the results to the current user's desktop as locked.csv


Search-ADAccount -LockedOut | Where {$_.UserPrincipalName -like "*microsoft.com*" -and $_.LastLogonDate -gt (Get-Date).AddDays(-30)} | Where {$_.Enabled -eq "True"} | Unlock-ADAccount


Same thing as the first line of code except instead of exporting the results, it unlocks those accounts shown in the results.


4 views0 comments
bottom of page