Options

SQL Clone image modifications

Hi all

We've got the hang on creating images and clones using PowerShell but now run into a new snag.

We've got a couple of modification scripts we want to run when the image is created but I'm getting error messages.

The first script
  • alters the clone owner to "sa" (that account is disabled but it keeps all the databases consistent)
  • drop a few stored procedures and functions that use some SQLCLR functions we've created
  • installs some new assemblies
  • rebuilds the stored procedures and functions to use the newly installed assemblies
This is the one that's failing.
This is the entire error message:-
An exception was thrown while executing a script: Microsoft.Data.SqlClient.SqlError: Cannot find the principal 'sa', because it does not exist or you do not have permission. Microsoft.Data.SqlClient.SqlError: User does not have permission to perform this action. Microsoft.Data.SqlClient.SqlError: ALTER DATABASE statement failed. Microsoft.Data.SqlClient.SqlError: User does not have permission to perform this action. Microsoft.Data.SqlClient.SqlError: You do not have permission to run the RECONFIGURE statement. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: UNSAFE ASSEMBLY permission was denied on object 'server', database 'master'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. Microsoft.Data.SqlClient.SqlError: Assembly 'CLR_Project' was not found in the SQL catalog of database 'SqlCloneTemp_woaa0lma'. (ScriptRunnerException)

The second script:-
  • Drop all foreign key constraints
  • truncates all the tables
  • repoints all synonyms to our test environment
  • recreates all the foreign key constrains

Both scripts work perfectly in SSMS but I can't get the first one to run from PowerShell so I don't know if the second one will run.

Any help on this would be appreciated.

Regards

Richard

Answers

Sign In or Register to comment.