ServiceNow - Table checks: check if table populated and last updated and updated by

 

function discoverTableInfo(tableName) { var bLog = true; //bLog=false; var grCMDB = new GlideRecord(tableName); grCMDB.orderByDesc('sys_updated_on'); grCMDB.query(); var iTotal = grCMDB.getRowCount(); if (iTotal > 0) { if (grCMDB.next()) { if (bLog) { gs.log('TABLE:' + tableName + ';' + 'TOTAL RECORDS:' + iTotal + ';' + ' last updated date:' + grCMDB.sys_updated_on + ' ;updated by=' + grCMDB.sys_updated_by, 'fixScript:itsm-16016'); } else { gs.print('TABLE:' + tableName + ';' + 'TOTAL RECORDS:' + iTotal + ';' + ' last updated date:' + grCMDB.sys_updated_on + ' ;updated by=' + grCMDB.sys_updated_by); } } } else { if (bLog) { gs.print('TABLE:' + tableName + ' IS EMPTY'); } else { gs.log('TABLE:' + tableName + ' IS EMPTY', 'fixScript:itsm-16016'); } } } var bTest = false; //bTest = true; if (bTest) { discoverTableInfo('cmdb_ci_azure_vm'); } else { discoverTableInfo('azure_action'); discoverTableInfo('azure_action_parameter'); discoverTableInfo('azure_alert_configuration'); discoverTableInfo('azure_alert_event'); discoverTableInfo('azure_alert_rule'); discoverTableInfo('azure_back_pool_back_ip_m2m'); discoverTableInfo('azure_back_pool_lb_out_rule_m2m'); discoverTableInfo('azure_back_pool_lb_rule_m2m'); discoverTableInfo('azure_billing_daily'); discoverTableInfo('azure_billing_monthly'); discoverTableInfo('azure_billing_text_block'); discoverTableInfo('azure_blob_snapshot'); discoverTableInfo('azure_datasource_type_mapping'); discoverTableInfo('azure_deployment'); discoverTableInfo('azure_deployment_operation'); discoverTableInfo('azure_deployment_output'); discoverTableInfo('azure_deployment_parameter'); discoverTableInfo('azure_ea_credential'); discoverTableInfo('azure_front_ip_lb_in_rule_m2m'); discoverTableInfo('azure_front_ip_lb_out_rule_m2m'); discoverTableInfo('azure_front_ip_lb_rule_m2m'); discoverTableInfo('azure_image_publisher'); discoverTableInfo('azure_job_config'); discoverTableInfo('azure_lb_inbound_nat_rule'); discoverTableInfo('azure_lb_outbound_nat_rule'); discoverTableInfo('azure_lb_probe'); discoverTableInfo('azure_lb_rule_probe_m2m'); discoverTableInfo('azure_load_balancing_rule'); discoverTableInfo('azure_offering_image_mapping'); discoverTableInfo('azure_opt_rule_vm'); discoverTableInfo('azure_region'); discoverTableInfo('azure_region_image_sub_mapping'); discoverTableInfo('azure_region_subscription_mapping'); discoverTableInfo('azure_report_download_log'); discoverTableInfo('azure_resource_type'); discoverTableInfo('azure_sas_credentials'); discoverTableInfo('azure_scheduled_script'); discoverTableInfo('azure_service_principal'); discoverTableInfo('azure_storage_accnts'); discoverTableInfo('azure_storage_account_key'); discoverTableInfo('azure_subscription'); discoverTableInfo('azure_template'); discoverTableInfo('azure_template_parameter'); discoverTableInfo('azure_template_to_variableset'); discoverTableInfo('azure_temp_param_ref_table_excl'); discoverTableInfo('azure_token_cache'); discoverTableInfo('azure_vm_size'); discoverTableInfo('azure_web_service'); discoverTableInfo('cmdb_ci_azure_approved_image'); discoverTableInfo('cmdb_ci_azure_availability_set'); discoverTableInfo('cmdb_ci_azure_blob'); discoverTableInfo('cmdb_ci_azure_container'); discoverTableInfo('cmdb_ci_azure_datacenter'); discoverTableInfo('cmdb_ci_azure_front_ip_config'); discoverTableInfo('cmdb_ci_azure_image'); discoverTableInfo('cmdb_ci_azure_ip_config'); discoverTableInfo('cmdb_ci_azure_lb_back_addr_pool'); discoverTableInfo('cmdb_ci_azure_load_balancer'); discoverTableInfo('cmdb_ci_azure_nic'); discoverTableInfo('cmdb_ci_azure_public_ip'); discoverTableInfo('cmdb_ci_azure_resource'); discoverTableInfo('cmdb_ci_azure_resource_group'); discoverTableInfo('cmdb_ci_azure_subnet'); discoverTableInfo('cmdb_ci_azure_subscription'); discoverTableInfo('cmdb_ci_azure_vhd'); discoverTableInfo('cmdb_ci_azure_vm'); discoverTableInfo('cmdb_ci_azure_vnet'); discoverTableInfo('discovery_azure_probe'); discoverTableInfo('ea_azure_credentials'); discoverTableInfo('imp_azure_billing'); discoverTableInfo('sc_azure_os_selection'); discoverTableInfo('sc_azure_template_cat_item'); discoverTableInfo('sc_azure_vm_cat_item'); discoverTableInfo('sn_azure_arm_template_link'); discoverTableInfo('sn_azure_vm_template_cat_item'); }

Comments

Popular posts from this blog

GlideRecord setValue

URL link in addInfoMessage