小编Joo*_*ost的帖子

使用 PowerShell 从 SSIS 目录中获取包 XML

有没有办法使用 PowerShell 从 SSIS 目录中的包中获取包 XML,但无需下载和解压缩项目?我想在 XML 文档中搜索某些字符串。

################################
########## PARAMETERS ##########
################################ 
$SsisServer = ".\sql2016"



############################
########## SERVER ##########
############################
# Load the Integration Services Assembly
$SsisNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
[System.Reflection.Assembly]::LoadWithPartialName($SsisNamespace) | Out-Null;

# Create a connection to the server
$SqlConnectionstring = "Data Source=" + $SsisServer + ";Initial Catalog=master;Integrated Security=SSPI;"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnectionstring

# Create the Integration Services object
$IntegrationServices = New-Object $SsisNamespace".IntegrationServices" $SqlConnection

# Check if connection succeeded
if (-not $IntegrationServices)
{
    Throw [System.Exception] "Failed to connect …
Run Code Online (Sandbox Code Playgroud)

xml powershell ssis

5
推荐指数
2
解决办法
2346
查看次数

使用ConvertTo-Json转换为JSON时保留数据类型名称

我正在尝试将我的SSIS目录环境导出到JSON文件(使用PowerShell).当我选择正确的列时,我将"String"和"Int16"视为Type的值: 在此输入图像描述 但是当我使用ConvertTo-Json转换为JSON时,它显示的是int值而不是字符串值: 在此输入图像描述 有什么建议?

在此输入图像描述

powershell json ssis

2
推荐指数
1
解决办法
506
查看次数

使用 PowerShell 循环遍历 JSON 文件

如何遍历 JSON 文件中的所有项目?当前代码只是将所有名称写在一个大行上:

Get-Content -Raw -Path c:\temp\Environments.Generic.json | ConvertFrom-Json | ForEach-Object {
    Write-Host $_.Name
}
Run Code Online (Sandbox Code Playgroud)

json文件:

[
   {
      "Name":"EnableRetry",
      "Description":"Enable retry for Webservice Task",
      "Type":"Boolean",
      "Sensitive":false,
      "Value":true
   },
   {
      "Name":"FolderStageFiles",
      "Description":"Location of stage files",
      "Type":"String",
      "Sensitive":false,
      "Value":"d:\\sources\\"
   },
   {
      "Name":"FtpPassword",
      "Description":"Secret FTP password",
      "Type":"String",
      "Sensitive":true,
      "Value":"Welcome1"
   }
]
Run Code Online (Sandbox Code Playgroud)

powershell json

2
推荐指数
1
解决办法
7212
查看次数

循环访问 Azure 对象并筛选标记

我有一个 Azure 对象(虚拟机、数据仓库或分析服务)的集合,我想遍历该集合,但也过滤掉具有特定标签的对象。

在此处输入图片说明

例如,获取所有没有名为“Environment”且值为“Production”的标签的Analysis Services 。

如何指定Where-Object过滤器(尝试了几种方法都没有成功)

cls

# Login to Azure
#Login-AzureRmAccount | Out-Null 

# Selecting the right subscription
#Select-AzureRmSubscription -SubscriptionName "MySubscription" | Out-Null 


# Get all my Analysis Services, but leave out those with the tag Environment=Production
$AnalysisServicesServers = Get-AzureRmAnalysisServicesServer | Where-Object {$_.Tag -notcontains @{Environment="Production";}}

# Loop Through the collection and to something
foreach ($AnalysisServicesServer in $AnalysisServicesServers)
{
    $AnalysisServicesServer                                                      # Show all properties
    Write-Host "1 Name $($AnalysisServicesServer.Name)"                          # Show Name
    Write-Host "2 Tags count [$($AnalysisServicesServer.Tag.Keys.Count)]"        # …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-powershell

2
推荐指数
1
解决办法
1716
查看次数

标签 统计

powershell ×4

json ×2

ssis ×2

azure ×1

azure-powershell ×1

xml ×1