45
function Get-UsersByGroup{
param(
[string]$groupName
)
$group = $vault.AdminService.GetGroupByName($groupName)
$groupInfo = $vault.AdminService.GetGroupInfoByGroupId($group.Id)
$groupInfo.Users | ForEach-Object { [array]$users += $_ }
return $users
}
$adminusers = Get-UsersByGroup 'Administrators'
Print via Inventor
$file = PrepareEnvironmentForFile "Catch Assembly.idw"
#region Settings
$printerName = "myPrinter"
$validExtensions = @("idw")
#endregion
$ext = $file.'File Extension'
if($validExtensions -notcontains $ext){
$powerJobs.Log.Warn("$ext is not a valid file extension")
exit 1
}
$publisher = $powerJobs.GetPublisher("PDF")
$publisher.OutputFile = "c:\temp\dummy.pdf"
$publisher.add_OnBeginPublish(
{
param($publisher, $PublishEventArgs)
$printManager = $PublishEventArgs.Document.PrintManager
$printManager.GetType().InvokeMember("Printer",[Reflection.BindingFlags]::SetProperty,
$null, $printManager, $printerName)
$printManager.ScaleMode = [Inventor.PrintScaleModeEnum]::kPrintBestFitScale
$printManager.PrintRange = [Inventor.PrintRangeEnum]::kPrintAllSheets
$printManager.PaperSize = [Inventor.PaperSizeEnum]::kPaperSizeA0
$printManager.SubmitPrint()
})
if (!$publisher.Open($file.Id)){
throw("Failed to open $($file.name)")
}
Retrive the user that queued the job
$jobQueue = $vault.JobService.GetJobsByDate(1000,[DateTime]::MinValue)
$currentJob = $jobQueue | Where-Object {$_.Id.Equals($powerJobs.Job.Id)}
$userinfo = $vault.AdminService.GetUserByUserId($currentJob.CreateUserId)
$email = $userinfo.Email
#place additional code here. Instead of writing the information to a textfile you
could send an email to the user
$userinfo | Out-File 'C:\Temp\user.txt'