compare - 使用 Powershell 比较两个 SQL 实例配置值
问题描述
我正在运行下面的两个 Powershell 脚本来比较两个 SQL Server 实例配置并返回差异。感谢原作者。我希望输出格式如下所示,仅显示配置值不同的配置值。现在,它显示来自 Instance1 的所有配置值,并且仅显示 Instance2 的配置值不同的地方。
#https://sqldbawithabeard.com/2017/02/
$WinSQl1 = 'SQLInstance1'
$WinSQl2 = 'SQLInstance2'
$Win1SPConfigure = Get-DbaSpConfigure -SqlInstance $WinSQl1
$Win2SPConfigure = Get-DbaSpConfigure -SqlInstance $WinSQl2
$propcompare = foreach ($prop in $Win1SPConfigure) {
[pscustomobject]@{
Config = $prop.DisplayName
$WinSQl1 = $prop.RunningValue
$WinSQl2 = $Win2SPConfigure | Where DisplayName -eq $prop.DisplayName | Where RunningValue -ne $prop.RunningValue | Select -ExpandProperty RunningValue
}
}
$propcompare | ogv
#https://therestisjustcode.wordpress.com/2017/09/12/t-sql-tuesday-94-automating-configuration-comparison/
$Server1 = Get-DbaSpConfigure -SqlInstance 'SQLInstance1'
$Server2 = Get-DbaSpConfigure -SqlInstance 'SQLInstance2'
Compare-Object -ReferenceObject $Server1 -DifferenceObject $Server2 -property ConfigName,RunningValue|Sort-Object ConfigName;
期望的输出
解决方案
推荐阅读
- c - Why does this program dispense the following canary values and assembly code?
- webserver - 如何从头开始制作 Web 服务器软件
- java - 在 GLSL 片段着色器中将 YUV (yCbCr420p) 转换为 RGB?
- javascript - 使用 Vue 动态绑定源禁用 HTML 音频元素
- ios - 将 UIButton 添加到 UIView 结果为白色文本
- android - 仅在收到第一条消息后才允许第二条消息
- c++ - OnVScroll() 没有在对话框菜单中被触发?
- javascript - 从字符串中删除除 1 种类型的字符之外的所有字符?
- postgresql - 如何在 PostgreSQL 中更新 json 空值
- pandas - 根据同一熊猫数据框中其他列中的值创建包含布尔值或 NaN 的新列