Thursday, February 24, 2022

Adobe PDF Script Calculate Age

 This is the script to calculate age in Adobe Acrobat Pro.  


This works but throws a internal error.


================================================

// Calculate Age 

// Ref: https://community.adobe.com/t5/acrobat-sdk-discussions/how-to-override-a-calculation-with-manual-entry-in-results-field/td-p/10856126


console.println("Calc Age Started");

var dobValue = getField("DOB").value;


if (dobValue!="") {


var dob = util.scand("mm/dd/yyyy", dobValue);


var today = new Date();


// compute years on full year only


var AgeCalulated = today.getFullYear() - dob.getFullYear();


// adjust for months before month of birth


if (today.getMonth() < dob.getMonth()) AgeCalulated = AgeCalulated - 1;


// adjust for today's month equal to dob's month and today's date before the date of birth


if ((today.getMonth() == dob.getMonth()) && (today.getDate() < dob.getDate())) AgeCalulated -= 1;


//event.value = AgeCalulated;

    console.println("Calc Age Proceess Start");

    getField("AGE").value=AgeCalulated;

    console.println("Calc Age Proceess Finished");


}

Thursday, February 3, 2022

Logoff Disconnected Users with 1 line of PowerShell

 This is the simple way to logoff disconnected users with 1 line of PowerShell


########################################################
# Script to log off Disconnected users on local users
# Ref: https://searchenterprisedesktop.techtarget.com/blog/Windows-Enterprise-Desktop/Logoff-Disconnected-Win10-Users-Via-Command-Line
# Ref Post By: Ed Tittel 24 Sep 2018
#######################################################
# Larry Billinghurst - 3 Feb 2022
#######################################################

quser | Select-String "Disc" |ForEach {logoff ($_.tostring() -split ' +')[2]}