SQL Server 2016 с использованием проверки подлинности SQL развертывает пакет служб SSIS в MSDB с помощью powershell - PullRequest
0 голосов
/ 17 октября 2019

Я использую следующий код для развертывания пакета служб SSIS с использованием проверки подлинности Windows в SQL Server 2016. Когда я пытался запустить его под проверкой подлинности SQL, всегда выдается следующая ошибка. И учетная запись пользователя, которую я пытаюсь использовать, имеет привилегии sysadmin.

Скрипт с использованием аутентификации Windows. В этом коде я изменил строку подключения, объясните в этой ссылке https://docs.microsoft.com/en-us/sql/integration-services/ssis-quickstart-deploy-powershell?view=sql-server-ver15 для аутентификации SQL.

 [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") | Out-Null

    #this allows the debug messages to be shown
    $DebugPreference = "Continue"

    # Retrieves a 2012 Integration Services CatalogFolder object
    # Creates one if not found
    Function Get-CatalogFolder
    {
        param
        (
            [string] $folderName
        ,   [string] $folderDescription
        ,   [string] $serverName = "localhost\dev2012"
        )

        $connectionString = [String]::Format("Data Source={0};Initial Catalog=msdb;Integrated Security=SSPI;", $serverName)

        $connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)

        $integrationServices = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices($connection)
        # The one, the only SSISDB catalog
        $catalog = $integrationServices.Catalogs["SSISDB"]

        $catalogFolder = $catalog.Folders[$folderName]

        if (-not $catalogFolder)
        {
            Write-Debug([System.string]::Format("Creating folder {0}", $folderName))
            $catalogFolder = New-Object Microsoft.SqlServer.Management.IntegrationServices.CatalogFolder($catalog, $folderName, $folderDescription)
            $catalogFolder.Create()
        }

        return $catalogFolder
    }

    # Deploy an ispac file into the SSISDB catalog
    Function Deploy-Project
    {
        param
        (
            [string] $projectPath
        ,   [string] $projectName
        ,   $catalogFolder
        )

        # test to ensure file exists
        if (-not $projectPath -or  -not (Test-Path $projectPath))
        {
            Write-Debug("File not found $projectPath")
            return
        }

        Write-Debug($catalogFolder.Name)
        Write-Debug("Deploying $projectPath")

        # read the data into a byte array
        [byte[]] $projectStream = [System.IO.File]::ReadAllBytes($projectPath)

        # $ProjectName MUST match the value in the .ispac file
        # else you will see 
        # Failed to deploy the project. Fix the problems and try again later.:The specified project name, test, does not match the project name in the deployment file.
        $projectName = "sample"

        $project = $catalogFolder.DeployProject($projectName, $projectStream)
    }

Сообщение об ошибке

Exception calling "Create" with "0" argument(s): "Operation 'Create' on object 'CatalogFolder[@Name='TestFolder']'
failed during execution."
At SCRIPT4.PS1:31 char:9
+         $catalogFolder.Create()
+         ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SfcCRUDOperationFailedException


Exception calling "DeployProject" with "2" argument(s): "The operation cannot be started by an account that uses SQL
Server Authentication. Start the operation with an account that uses Windows Authentication."
  SCRIPT4.PS1:65 char:5
+     $project = $catalogFolder.DeployProject($projectName, $projectStr ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SqlException

Итак, в итоге

В SQL Server 2016 с использованием аутентификации SQL возможно развертывание пакета служб SSIS в MSDB с использованием powershell ??

1 Ответ

0 голосов
/ 18 октября 2019

Измените строку подключения на

Data Source={0};Initial Catalog=msdb;uid=sqlUser;pwd=sqlPassword;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...