|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en-US"> |
| 3 | +<head> |
| 4 | +<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0"> |
| 5 | +<title>Compare-sqmServerConfiguration — sqmSQLTool</title> |
| 6 | +<meta name="description" content="Compares SQL Server instance configuration (sp_configure values, instance properties, optional database settings) between two instances and returns differences."> |
| 7 | +<meta name="keywords" content="sqmSQLTool,PowerShell,SQL Server,configuration compare,Compare-sqmServerConfiguration"> |
| 8 | +<meta name="author" content="dtcSoftware"> |
| 9 | +<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","headline":"Compare-sqmServerConfiguration","description":"Compare SQL Server configuration settings between two instances","author":{"@type":"Organization","name":"dtcSoftware"}}</script> |
| 10 | +<style> |
| 11 | +:root{--n:#1a1a2e;--b:#5dade2;--c:#00c8e8;--p:#7c3aed;--bg:#060f20;--sf:rgba(255,255,255,.04);--br:rgba(46,134,193,.25);--tx:#e2e8f0;--mu:#94a8c0;--cb:#012456;--ct:#e8e8e8} |
| 12 | +*{box-sizing:border-box;margin:0;padding:0}html,body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--tx);line-height:1.6} |
| 13 | +header{background:linear-gradient(135deg,var(--n),var(--b));padding:20px 0;border-bottom:2px solid var(--c);position:sticky;top:0;z-index:100;box-shadow:0 2px 8px rgba(0,0,0,.3)} |
| 14 | +.hc{max-width:1000px;margin:0 auto;padding:0 24px;display:flex;justify-content:space-between;align-items:center} |
| 15 | +.logo{font-size:1.2rem;font-weight:900;color:#fff;text-decoration:none} |
| 16 | +.bc{font-size:.9rem;color:var(--mu)}.bc a{color:var(--c);text-decoration:none;margin:0 4px}.bc a:hover{text-decoration:underline} |
| 17 | +main{max-width:960px;margin:0 auto;padding:40px 24px} |
| 18 | +.cn{font-family:"Cascadia Code","Consolas",monospace;font-size:1.9rem;font-weight:900;color:var(--c);margin-bottom:12px} |
| 19 | +.cm{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin-bottom:24px} |
| 20 | +.badge{padding:6px 14px;border-radius:20px;font-size:.82rem;font-weight:700;text-transform:uppercase;color:#fff} |
| 21 | +.desc{background:var(--sf);border:1px solid var(--br);border-radius:8px;padding:20px;margin-bottom:28px;font-size:1rem;line-height:1.8;color:var(--mu)} |
| 22 | +.st{font-size:1.3rem;font-weight:800;color:var(--c);border-bottom:2px solid var(--p);padding-bottom:8px;margin-bottom:16px} |
| 23 | +section{margin-bottom:32px} |
| 24 | +table{width:100%;border-collapse:collapse;font-size:.88rem} |
| 25 | +th{background:rgba(46,134,193,.2);color:var(--c);padding:9px 14px;text-align:left;font-weight:700;border-bottom:2px solid var(--br)} |
| 26 | +td{padding:9px 14px;border-bottom:1px solid var(--br);color:var(--mu);vertical-align:top} |
| 27 | +tr:hover td{background:rgba(0,200,232,.04)} |
| 28 | +td:first-child{font-family:"Cascadia Code","Consolas",monospace;color:var(--c);font-size:.84rem;white-space:nowrap} |
| 29 | +.tr{display:inline-block;background:rgba(239,68,68,.2);color:#ef4444;border:1px solid #ef4444;border-radius:4px;padding:1px 7px;font-size:.68rem;font-weight:700;text-transform:uppercase} |
| 30 | +.to{display:inline-block;background:rgba(34,197,94,.15);color:#22c55e;border:1px solid #22c55e;border-radius:4px;padding:1px 7px;font-size:.68rem;font-weight:700;text-transform:uppercase} |
| 31 | +.ts{display:inline-block;background:rgba(245,158,11,.15);color:#f59e0b;border:1px solid #f59e0b;border-radius:4px;padding:1px 7px;font-size:.68rem;font-weight:700;text-transform:uppercase} |
| 32 | +.dv{font-family:"Cascadia Code","Consolas",monospace;font-size:.8rem;color:#f59e0b} |
| 33 | +.fw{background:var(--sf);border:1px solid var(--br);border-radius:8px;padding:20px 12px;overflow-x:auto;text-align:center} |
| 34 | +.fw svg{max-width:100%;height:auto} |
| 35 | +.example{background:var(--sf);border:1px solid var(--br);border-radius:8px;margin-bottom:14px;overflow:hidden} |
| 36 | +.exl{background:rgba(46,134,193,.2);padding:11px 16px;font-size:.86rem;font-weight:600;color:var(--c);border-bottom:1px solid var(--br);font-family:"Cascadia Code",monospace;word-break:break-all} |
| 37 | +.cw{position:relative;padding:14px} |
| 38 | +pre.cb{background:var(--cb);color:var(--ct);padding:12px 14px;border-radius:4px;font-family:"Cascadia Code","Consolas","Courier New",monospace;font-size:.88rem;line-height:1.6;overflow-x:auto;white-space:pre-wrap;word-wrap:break-word} |
| 39 | +.cp{position:absolute;top:18px;right:18px;background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.2);color:#94a3b8;padding:5px 11px;border-radius:4px;font-size:.78rem;cursor:pointer;transition:all .2s;font-family:inherit} |
| 40 | +.cp:hover{background:rgba(0,200,232,.2);color:var(--c);border-color:var(--c)}.cp.ok{background:rgba(76,175,80,.2);color:#4caf50;border-color:#4caf50} |
| 41 | +.nav{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-top:50px;padding-top:32px;border-top:1px solid var(--br)} |
| 42 | +.nl{display:block;padding:18px;background:var(--sf);border:1px solid var(--br);border-radius:8px;text-decoration:none;transition:all .3s} |
| 43 | +.nl:hover{background:rgba(0,200,232,.08);border-color:var(--c)} |
| 44 | +.nll{font-size:.78rem;color:var(--mu);text-transform:uppercase;letter-spacing:.5px;margin-bottom:6px} |
| 45 | +.nlt{font-size:.95rem;font-weight:700;color:var(--c);font-family:"Cascadia Code",monospace} |
| 46 | +footer{background:var(--sf);border-top:1px solid var(--br);padding:36px 24px;margin-top:50px;text-align:center;color:var(--mu);font-size:.88rem} |
| 47 | +footer a{color:var(--c);text-decoration:none} |
| 48 | +@media(max-width:768px){.cn{font-size:1.4rem}.hc{flex-direction:column;gap:10px;text-align:center}.nav{grid-template-columns:1fr}main{padding:20px 14px}} |
| 49 | +</style> |
| 50 | +</head> |
| 51 | +<body> |
| 52 | +<header><div class="hc"> |
| 53 | +<a href="https://powershelldba.de/" class="logo">🔢 sqmSQLTool</a> |
| 54 | +<div class="bc"><a href="index.html">Commands</a> / <span>Compare-sqmServerConfiguration</span></div> |
| 55 | +</div></header> |
| 56 | +<main> |
| 57 | +<div class="cn">Compare-sqmServerConfiguration</div> |
| 58 | +<div class="cm"> |
| 59 | +<span class="badge" style="background:#0369a1">Configuration</span> |
| 60 | +<span style="color:var(--mu)">sqmSQLTool v1.8.2+ · Compare</span> |
| 61 | +</div> |
| 62 | +<section class="desc"> |
| 63 | +Compares important configuration settings between a <strong>source</strong> and a <strong>target</strong> SQL Server instance and returns only the differences as <code>[PSCustomObject]</code> rows. |
| 64 | +<br><br> |
| 65 | +Instance-level properties compared: <code>Version</code>, <code>Edition</code>, <code>LoginMode</code>, <code>MaxMemory</code>, <code>MinMemory</code>, <code>MaxDop</code>, <code>CostThresholdForParallelism</code>, <code>BackupDirectory</code>, <code>DefaultFile</code>, <code>DefaultLog</code>. <strong>Collation</strong> is always included as a reference row regardless of match. |
| 66 | +<br><br> |
| 67 | +With <code>-CompareDatabases</code>, user databases are also compared: <code>Owner</code>, <code>RecoveryModel</code>, and <code>Collation</code> per database. Missing databases on either side are reported as <code><missing></code>. |
| 68 | +</section> |
| 69 | + |
| 70 | +<section><h2 class="st">Parameters</h2> |
| 71 | +<table><thead><tr><th>Parameter</th><th>Type</th><th>Required</th><th>Default</th><th>Notes</th></tr></thead> |
| 72 | +<tbody> |
| 73 | +<tr><td>-SourceInstance</td><td>string</td><td><span class="tr">Required</span></td><td><span class="dv">—</span></td><td>Reference SQL Server instance.</td></tr> |
| 74 | +<tr><td>-TargetInstance</td><td>string</td><td><span class="tr">Required</span></td><td><span class="dv">—</span></td><td>Instance to compare against the source.</td></tr> |
| 75 | +<tr><td>-SqlCredential</td><td>PSCredential</td><td><span class="to">Optional</span></td><td><span class="dv">—</span></td><td>Used for both instance connections. For different credentials per instance, connect manually first.</td></tr> |
| 76 | +<tr><td>-CompareDatabases</td><td>switch</td><td><span class="ts">Switch</span></td><td><span class="dv">$false</span></td><td>Also compare user databases (Owner, RecoveryModel, Collation). Missing databases are flagged.</td></tr> |
| 77 | +<tr><td>-EnableException</td><td>switch</td><td><span class="ts">Switch</span></td><td><span class="dv">$false</span></td><td>Throw on error instead of returning <code>$null</code>.</td></tr> |
| 78 | +</tbody></table> |
| 79 | +</section> |
| 80 | + |
| 81 | +<section><h2 class="st">Execution Flow</h2> |
| 82 | +<div class="fw"> |
| 83 | +<svg viewBox="0 0 760 580" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif" font-size="12"> |
| 84 | +<defs> |
| 85 | +<marker id="a" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto"><path d="M0,0 L0,6 L8,3 z" fill="#5dade2"/></marker> |
| 86 | +<marker id="ar" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto"><path d="M0,0 L0,6 L8,3 z" fill="#ef4444"/></marker> |
| 87 | +</defs> |
| 88 | + |
| 89 | +<!-- START --> |
| 90 | +<ellipse cx="380" cy="30" rx="80" ry="22" fill="#1a1a2e" stroke="#00c8e8" stroke-width="2"/> |
| 91 | +<text x="380" y="35" text-anchor="middle" fill="#00c8e8" font-weight="bold">START</text> |
| 92 | +<line x1="380" y1="52" x2="380" y2="72" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 93 | + |
| 94 | +<!-- dbatools installed? --> |
| 95 | +<polygon points="380,73 480,105 380,137 280,105" fill="#0d1b2e" stroke="#ef4444" stroke-width="1.5"/> |
| 96 | +<text x="380" y="101" text-anchor="middle" fill="#ef4444" font-weight="bold" font-size="11">dbatools</text> |
| 97 | +<text x="380" y="115" text-anchor="middle" fill="#ef4444" font-weight="bold" font-size="11">installed?</text> |
| 98 | +<line x1="280" y1="105" x2="172" y2="105" stroke="#ef4444" stroke-width="1.5" marker-end="url(#ar)"/> |
| 99 | +<text x="268" y="99" text-anchor="end" fill="#ef4444" font-size="11">NO</text> |
| 100 | +<rect x="20" y="85" width="150" height="40" rx="5" fill="rgba(239,68,68,.15)" stroke="#ef4444" stroke-width="1.5"/> |
| 101 | +<text x="95" y="101" text-anchor="middle" fill="#ef4444" font-weight="bold" font-size="10">throw:</text> |
| 102 | +<text x="95" y="115" text-anchor="middle" fill="#ef4444" font-size="10">dbatools not found</text> |
| 103 | +<text x="394" y="148" fill="#22c55e" font-size="11">YES</text> |
| 104 | +<line x1="380" y1="137" x2="380" y2="157" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 105 | + |
| 106 | +<!-- Connect + get props --> |
| 107 | +<rect x="130" y="158" width="500" height="44" rx="5" fill="#0d1b2e" stroke="#94a8c0" stroke-width="1.5"/> |
| 108 | +<text x="380" y="176" text-anchor="middle" fill="#94a8c0" font-weight="bold" font-size="11">Connect-DbaInstance → Get-ServerProps</text> |
| 109 | +<text x="380" y="194" text-anchor="middle" fill="#e2e8f0" font-size="10">SourceInstance + TargetInstance: Version, Edition, LoginMode, MaxMemory, MinMemory, MaxDop, CTP, BackupDir, DefaultFile, DefaultLog</text> |
| 110 | +<line x1="380" y1="202" x2="380" y2="222" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 111 | + |
| 112 | +<!-- Compare instance props --> |
| 113 | +<rect x="130" y="223" width="500" height="44" rx="5" fill="#0d1b2e" stroke="#94a8c0" stroke-width="1.5"/> |
| 114 | +<text x="380" y="241" text-anchor="middle" fill="#94a8c0" font-weight="bold" font-size="11">Compare instance properties</text> |
| 115 | +<text x="380" y="255" text-anchor="middle" fill="#e2e8f0" font-size="10">foreach key: Source ≠ Target → add to $results | Collation always added (reference row)</text> |
| 116 | +<line x1="380" y1="267" x2="380" y2="287" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 117 | + |
| 118 | +<!-- CompareDatabases? --> |
| 119 | +<polygon points="380,288 480,320 380,352 280,320" fill="#0d1b2e" stroke="#5dade2" stroke-width="1.5"/> |
| 120 | +<text x="380" y="315" text-anchor="middle" fill="#e2e8f0" font-weight="bold" font-size="11">-CompareDatabases</text> |
| 121 | +<text x="380" y="329" text-anchor="middle" fill="#e2e8f0" font-weight="bold" font-size="11">set?</text> |
| 122 | +<!-- NO right → skip --> |
| 123 | +<line x1="480" y1="320" x2="596" y2="320" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 124 | +<text x="488" y="314" fill="#ef4444" font-size="11">NO</text> |
| 125 | +<rect x="516" y="302" width="160" height="36" rx="5" fill="rgba(0,0,0,.3)" stroke="#94a8c0" stroke-width="1.5"/> |
| 126 | +<text x="596" y="316" text-anchor="middle" fill="#94a8c0" font-size="10">skip database</text> |
| 127 | +<text x="596" y="330" text-anchor="middle" fill="#94a8c0" font-size="10">comparison</text> |
| 128 | +<line x1="596" y1="338" x2="596" y2="422" stroke="#5dade2" stroke-width="1.5"/> |
| 129 | +<line x1="596" y1="422" x2="382" y2="422" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 130 | +<!-- YES down --> |
| 131 | +<text x="394" y="363" fill="#22c55e" font-size="11">YES</text> |
| 132 | +<line x1="380" y1="352" x2="380" y2="372" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 133 | + |
| 134 | +<!-- Compare databases --> |
| 135 | +<rect x="130" y="373" width="500" height="44" rx="5" fill="#0d1b2e" stroke="#94a8c0" stroke-width="1.5"/> |
| 136 | +<text x="380" y="391" text-anchor="middle" fill="#94a8c0" font-weight="bold" font-size="11">Get-DbaDatabase both instances → compare per DB</text> |
| 137 | +<text x="380" y="407" text-anchor="middle" fill="#e2e8f0" font-size="10">Owner, RecoveryModel, Collation | missing on either side → <missing> row</text> |
| 138 | +<!-- merge from NO branch at y=422 --> |
| 139 | +<line x1="380" y1="417" x2="380" y2="422" stroke="#5dade2" stroke-width="1.5"/> |
| 140 | +<line x1="380" y1="422" x2="380" y2="442" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 141 | + |
| 142 | +<!-- Return $results --> |
| 143 | +<rect x="170" y="443" width="420" height="36" rx="5" fill="#0d1b2e" stroke="#94a8c0" stroke-width="1.5"/> |
| 144 | +<text x="380" y="457" text-anchor="middle" fill="#94a8c0" font-weight="bold" font-size="11">Return $results</text> |
| 145 | +<text x="380" y="471" text-anchor="middle" fill="#e2e8f0" font-size="10">[PSCustomObject[]] Setting, SourceValue, TargetValue, Category</text> |
| 146 | +<line x1="380" y1="479" x2="380" y2="499" stroke="#5dade2" stroke-width="1.5" marker-end="url(#a)"/> |
| 147 | + |
| 148 | +<!-- DONE --> |
| 149 | +<ellipse cx="380" cy="522" rx="100" ry="22" fill="#1a1a2e" stroke="#22c55e" stroke-width="2"/> |
| 150 | +<text x="380" y="527" text-anchor="middle" fill="#22c55e" font-weight="bold">DONE</text> |
| 151 | +</svg> |
| 152 | +</div> |
| 153 | +</section> |
| 154 | + |
| 155 | +<section><h2 class="st">Examples</h2> |
| 156 | + |
| 157 | +<div class="example"> |
| 158 | +<div class="exl">Compare two instances — instance-level settings only</div> |
| 159 | +<div class="cw"><button class="cp" onclick="navigator.clipboard.writeText(this.nextElementSibling.innerText).then(()=>{this.textContent='Copied!';this.classList.add('ok');setTimeout(()=>{this.textContent='Copy';this.classList.remove('ok')},2000)})">Copy</button> |
| 160 | +<pre class="cb">Compare-sqmServerConfiguration -SourceInstance "SQL01" -TargetInstance "SQL02"</pre> |
| 161 | +</div></div> |
| 162 | + |
| 163 | +<div class="example"> |
| 164 | +<div class="exl">Include database-level comparison and format as table</div> |
| 165 | +<div class="cw"><button class="cp" onclick="navigator.clipboard.writeText(this.nextElementSibling.innerText).then(()=>{this.textContent='Copied!';this.classList.add('ok');setTimeout(()=>{this.textContent='Copy';this.classList.remove('ok')},2000)})">Copy</button> |
| 166 | +<pre class="cb">Compare-sqmServerConfiguration -SourceInstance "SQL01" -TargetInstance "SQL02" -CompareDatabases | Format-Table</pre> |
| 167 | +</div></div> |
| 168 | + |
| 169 | +</section> |
| 170 | + |
| 171 | +<div class="nav"> |
| 172 | +<a href="index.html" class="nl"><div class="nll">← Back</div><div class="nlt">Command Index</div></a> |
| 173 | +<a href="export-sqmserverconfiguration.html" class="nl"><div class="nll">Related</div><div class="nlt">Export-sqmServerConfiguration</div></a> |
| 174 | +</div> |
| 175 | +</main> |
| 176 | +<footer> |
| 177 | +<p>sqmSQLTool — SQL Server DBA Automation — <a href="https://powershelldba.de/">powershelldba.de</a></p> |
| 178 | +<p style="margin-top:8px;font-size:.8rem">dtcSoftware · Module v1.8.2+</p> |
| 179 | +</footer> |
| 180 | +<script>document.querySelectorAll('.cp').forEach(b=>{b.addEventListener('click',()=>{})});</script> |
| 181 | +</body> |
| 182 | +</html> |
0 commit comments