我正在使用下面的 Powershell 工作流脚本。我在 Windows ISE 上运行它。
我无法打印变量 $ElasticPoolList 来查看输出。
谁能告诉我,如何打印 PowerShell 工作流的变量。
clear-host
workflow index_job {
$FullServerName='dev.database.windows.net'
$masterDB='master'
$UserName='someUserName'
$Password= 'somePassword'
$ElasticPoolList = inlinescript{
$UserName =$Using:UserName
$Password = $Using:Password
$ServerName = $Using:ServerName
$FullServerName = $Using:FullServerName
$masterDB = $Using:masterDB
$ElasticPoolListDBNames=@"
SELECT DISTINCT elastic_pool_name
FROM sys.database_service_objectives
WHERE elastic_pool_name IS NOT NULL
UNION ALL
SELECT d.name AS elastic_pool_name
FROM sys.databases d
INNER JOIN sys.database_service_objectives dso ON d.database_id = dso.database_id
WHERE d.Name <> 'master'
AND dso.elastic_pool_name IS NULL
"@
$ElasticPoolListDBNames_Conn=Invoke-Sqlcmd -ServerInstance $FullServerName -Database $masterDB -Username $UserName -Password $Password -Query $ElasticPoolListDBNames
}
$ElasticPoolList
foreach -parallel($pool in $ElasticPoolList){
Write-output "Inside Pool:" $pool
}
}
# To call the workflow
index_job
在输出窗口中,我想将输出打印为