ライセンスされたユーザー(役割に割り当てられたユーザー)の数のカウント

この項のスクリプトを使用して役割割当レポートを生成し、環境のユーザー数をカウントします。

次のスクリプトをコピーすることで、provisionedUsersCount.batを作成します。

注:

  • provisionedUsersCount.batを実行するための入力パラメータは、usernamepassword/password_fileservice_urlおよびreport_file_nameです。たとえば、コマンド・プロンプトで、次のようなコマンドを入力します。

    provisionedUsersCount.bat jdoe password.epw https://example.oraclecloud.com myRole_assign.CSV

  • パスワードに特殊文字が含まれている場合は、特殊文字の処理を参照してください。
@echo off

set paramRequiredMessage=Syntax: provisionedUsersCount.bat USERNAME PASSWORD/PASSWORD_FILE URL REPORT_FILE_NAME

if "%~1" == "" (
      echo User Name is missing.
        echo %paramRequiredMessage%
        exit /b 1
  )

if "%~2" == "" (
        echo Password or Password_File is missing.
        echo %paramRequiredMessage%
        exit /b 1
  )

if "%~3" == "" (
        echo URL is missing.
        echo %paramRequiredMessage%
        exit /b 1
  )

if "%~4" == "" (
        echo Role Assignment Report File Name is missing.
        echo %paramRequiredMessage%
        exit /b 1
  )

call epmautomate.bat login %~1 "%~2" %~3 
REM call epmautomate.bat login %~1 "%~2" %~3

if %errorlevel% NEQ 0 exit /b 1
   call epmautomate.bat roleAssignmentReport "%5"
if %errorlevel% NEQ 0 exit /b 1
   call epmautomate.bat downloadFile "%5"
if %errorlevel% NEQ 0 exit /b 1

set filePath="%cd%\%4"

if exist %filePath% (
        SETLOCAL EnableDelayedExpansion
        set /a lineCount=0
        set /a userCount=0
        set userHeaderFound=false
        for /f "tokens=*" %%A in ( 'type %filePath%' ) do (
                set /a lineCount+=1
                set line=%%A
                
                REM Fetch username from role assignment information row
                if !userHeaderFound!==true (
                        for /f "delims=," %%i in ("!line!") do (
                                set userName=%%i
        )
                if NOT !userName! == "" (
                  if !userCount! gtr 0 if NOT !userName! == !lastUserName! (
                          set /a userCount+=1
        set users[!userCount!]=!userName!
                                )
                if !userCount! == 0 (
                                set /a userCount+=1
                                set users[!userCount!]=!userName!
                                )
      set lastUserName=!userName!
                        )
                )

                REM Check for headers of Role Assignment Report
                if "!line!"=="User Login,First Name,Last Name,Email,Role,Granted through Group" (
                                set userHeaderFound=true
                    )
    if "!line!"=="User Login,First Name,Last Name,Email,Roles,Granted Through" (
        set userHeaderFound=true
                 )
        )

        echo Number of Users: !userCount!
        for /l %%n in (1,1,!userCount!) do ( 
  REM echo !users[%%n]!
        )
        endlocal

) else (
          echo Invalid provisioning report file path - %filePath%.
)