I am trying to use your script but i found.....
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near 'show advanced options'.
Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
The configuration option 'Ole Automation Procedures' does not exist, or it may be an advanced option.
Msg 102, Level 15, State 1, Line 41
Incorrect syntax near 'sp_configure'.
Configuration option 'show advanced options' changed from 0 to 0. Run the RECONFIGURE statement to install.