05-21-2016 09:05 AM
05-22-2016 02:38 AM
Another way to achieve the same thing, is to list all policies, and then list each client in each policy, and then sort the output.
.
@echo off setlocal enabledelayedexpansion set z_script_path=%~dp0 set z_script_name=%~n0 set z_file_csv=!z_script_path!!z_script_name!.csv set z_file_lis=!z_script_path!!z_script_name!.lis set z_file_log=!z_script_path!!z_script_name!.log set z_file_pol=!z_script_path!!z_script_name!.pol set z_file_tmp=!z_script_path!!z_script_name!.tmp if exist "!z_file_csv!" del "!z_file_csv!" if exist "!z_file_lis!" del "!z_file_lis!" if exist "!z_file_pol!" del "!z_file_pol!" if exist "!z_file_tmp!" del "!z_file_tmp!" set /a z_policy_count=0 set /a z_client_count=0 call :log "" call :log "Listing policies..." bppllist >"!z_file_pol!" 2>&1 set z_sts=!errorlevel! if not !z_sts!==0 ( call :log "...call to bppllist failed, status `!z_sts!`, script aborting..." goto :end ) call :log "...done..." call :log "" call :log "Listing clients in policies..." for /f "tokens=1" %%a in ('type "!z_file_pol!"') do ( set z_policy_name=%%a call :log "...listing policy `!z_policy_name!`..." bppllist !z_policy_name! >"!z_file_tmp!" 2>&1 set z_sts=!errorlevel! if !z_sts!==0 ( call :r_process_policy ) else ( call :log "...failed to list policy, status `!z_sts!`, script continuing..." ) ) call :log "...policies read: !z_policy_count!" call :log "...clients listed: !z_client_count!" call :log "...done..." call :log "" call :log "Sorting..." sort "!z_file_lis!" /o "!z_file_csv!" set z_sts=!errorlevel! if not !z_sts!==0 ( call :log "...call to sort failed, status `!z_sts!`, script aborting..." goto :end ) call :log "...output file is: !z_file_csv!" call :log "...done..." :end call :log "" call :log "Script exiting..." echo+ pause exit /b :r_process_policy set /a z_policy_count+=1 for /f "tokens=1,2,3,4" %%a in ('type "!z_file_tmp!"') do ( if "%%a"=="CLIENT" ( set z_client_name=%%b set z_client_hardware=%%c set z_client_os=%%d (echo !z_client_name!,!z_client_hardware!,!z_client_os!,!z_policy_name!)>>"!z_file_lis!" set /a z_client_count+=1 ) ) goto :eof :log (echo !date! !time:~0,8! %~1) (echo !date! !time:~0,8! %~1)>>"!z_file_log!" goto :eof
05-22-2016 02:43 AM
The script assumes that you have the path to the NetBackup binaries already defined in your system wide "PATH".
See mph999's super post about making your life easier with NetBackup:
https://www.veritas.com/community/articles/making-your-life-easier-netbackup
05-22-2016 03:53 AM