public/Get-InactiveAccounts.ps1

function Get-InactiveAccounts {

    Param(
        [int] $DaysInactive = 30,
        [Parameter(Mandatory)]  
        [ValidateSet('Users','Computers')]
        $Object
        )

    if ($Object -eq 'Users') {
        
        Search-ADAccount -UsersOnly -AccountInactive -TimeSpan "$DaysInactive.00:00:00" | Sort LastLogonDate | Select Name,LastLogonDate

    }

    if ($Object -eq 'Computers') {
        
        Search-ADAccount -ComputersOnly -AccountInactive -TimeSpan "$DaysInactive.00:00:00" | Sort LastLogonDate | Select Name,LastLogonDate
    
    }

}