0

我正在使用以下代码在 SQL Server 2016 中使用 Windows 身份验证部署 SSIS 包。当我尝试在 SQL 身份验证下运行它时,它总是给出以下错误。以及我尝试使用的具有系统管理员权限的用户帐户。

使用 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 身份验证的 SQL Server 2016 中,可以使用 powershell 在 MSDB 中部署 SSIS 包?

4

1 回答 1

-1

将连接字符串更改为

Data Source={0};Initial Catalog=msdb;uid=sqlUser;pwd=sqlPassword;
于 2019-10-18T12:24:18.483 回答