Skip to main content

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

Get URL Parameter - server side script (portal or classic UI)

Classic UI : var sURL_editparam = gs . action . getGlideURI (). getMap (). get ( ' sysparm_aparameter ' ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); } Portal : var sURL_editparam = $sp . getParameter ( " sysparm_aparameter " ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); }

ServiceNow - script include: build up the results as a JSON object (array) - example 2

function call var sCurrentGroupMembers = new <script_include> (). getGroupMembers ( group_sysid ); gs . print ( 'sCurrentGroupMembers:' + sCurrentGroupMembers ); var oGroupMembers = JSON . parse ( sCurrentGroupMembers ); gs . print ( JSON . stringify ( oGroupMembers . users )); oNewGroupMember = JSON . parse ( group_members ); var oGroupConfig = getGroupDeltas ( oGroupMembers . users , oNewGroupMember ); gs . print ( JSON . stringify ( oGroupConfig . remove )); gs . print ( JSON . stringify ( oGroupConfig . add )) output : *** Script: sCurrentGroupMembers: {"manager":"3b2649efdb0f8c10cc0652f3f39xxxxx", "email":"", "type":"33a2226edb99c340edfc7cbdae96xxxx", "description":"Created for xyz", "users":[{"user":"3b2649efdb0f8c10cc0652f3f396xxxx"},{"user":"856a8f71db3d73041b4ffc45ae96196a"},{"user":"3752771