Skip to Content

We had requirement to develop automated script which is scheduled to run on daily based during off-hours for verify and repair of MDM repository. I am writing this blog to explain the steps I followed to write the script. I should have written the code snippet in Wiki; but including in MDM section as the script will be of use not only for developers i.e. it may be of immense help for basis consultants and in some cases functional consultants.

Following points need to be considered.

1. As CLIX commands require credentials to be supplied along with the command; we need to find better way to secure credentials instead of supplying along with the command in script file

2. As the repair needs repository to be stopped, we need to first trigger CLIX verify command on the repository. If the outcome of this is error, then only trigger repair

3. For verification of the repository, we need to check if the repository is available using CLIX repIsAvailable command. If repository is not busy, the script returns available

4. Trigger Verify using CLIX command repCheck. If this ends in error fatal; it means repository needs repair

5. Stop the repository.

6. If the stop is successful, then trigger the repair

7. update the outcome of the repair i.e. fatal error or successful to the stakeholders.

For secure storage of database and repository credentials, we can make use of Windows Credentials Manager. There are number of open source powershell scripts which provide access to stored credentials. Refer screen shot present at last.

Following commands can be used in sequence for the repository availability, repository verify, if repair is required then stop and repair the repository.

                 $MDMRepCredentials = & CredentialsFetch.ps1 ‘MDM_REP’

                 $MDMDBCredentials = & CredentialsFetch.ps1 ‘MDM_DB’

                 if($MDMRepCredentials -eq ‘NOTFOUND’)

                {

                                echo “MDM Repository Credentials are not maintained. Hence exiting the script”

                                break

                }

                if($MDMDBCredentials -eq ‘NOTFOUND’)

                {

                                echo “MDM DB Credentials are not maintained. Hence exiting the script”

                                break

                }

                 echo “Trigger Repository Verify as first step”

               CLIX repCheck server VerifyReparRep:server:S:$MDMDBCredentials $MDMRepCredentials

                $RC=$?

                 if($RC -eq ‘false’)

                {

                     echo”Verify check shows there was fatal error; which means repair is required”

                     do

                     {            

                                $RepAvailability  = CLIX repIsAvailable server VerifyReparRep:server:S:$MDMDBCredentials [-T –TIMELOOP 60] [-

W] [-D]

                                $RC=$? # This capture whether fatal error is the result of command execution.

                                if($RC -eq ‘false’)

                                 {

                                  echo ” Repository Availability check resulted in exception. Exiting the script”

                                   break                

                                }            

                                  #wait for 5 miutes and give a try

                                #Start-Sleep -sec 300

                     }While(!($RepAvailability -eq “available”))          

                if($RepAvailability -eq “available”)

                {

                                echo “Stop the repository for repair as it is available for maintenance activities”

                                CLIX repStop  server VerifyReparRep:server:S:$MDMDBCredentials $MDMRepCredentials

                                $RC=$?

                                if($RC -eq ‘true’)

                                 {

                                   echo “Trigger repair as Stop comamnd executed successfully”

                                CLIX repStop  server VerifyReparRep:server:S:$MDMDBCredentials $MDMRepCredentials                                                        

                                                 if($RC -eq ‘true’)

                                                {            

                                                                echo “Repair completed successfully”

                                                }

                                               else

                                               {

                                                       echo “repository repair ended in error. Needs immediate attention”

                                                 }

                               }

                                else

                                {

                                echo “Repository stop trigger ended in fatal error. Exiting the script”

              }

            }

       }            

Capture.JPG

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply