Files
RDPSign/README.html
T

342 lines
18 KiB
HTML
Raw Normal View History

<h1 id="rdp---intunewin-pakke">RDP - IntuneWin Pakke</h1>
<blockquote>
<p>Denne pakke installerer og signerer RDP-genveje på skrivebordet via
et selvsigneret certifikat, så brugerne ikke får en sikkerhedsadvarsel
ved åbning. Som standard arbejder alle scripts mod det
<strong>offentlige skrivebord</strong>
(<code>C:\Users\Public\Desktop</code>). Brug <code>-AllUsers</code>
switchen for at køre mod alle brugeres individuelle skriveborde i
stedet.
</p>
</blockquote>
<hr />
<h2 id="indhold">Indhold</h2>
<ul>
<li><a href="#pakkens-indhold">Pakkens indhold</a></li>
<li><a href="#intune-app-konfiguration">Intune App
Konfiguration</a></li>
<li><a href="#hvad-install.ps1-gør">Hvad Install.ps1 gør</a></li>
<li><a href="#sådan-opsætter-du-detect.ps1">Sådan opsætter du
Detect.ps1</a></li>
<li><a href="#allusers-switch">AllUsers Switch</a></li>
<li><a href="#registry-ændringer">Registry-ændringer</a></li>
<li><a href="#logning-og-fejlfinding">Logning og fejlfinding</a></li>
<li><a href="#signonly-intune-app-konfiguration">SignOnly Intune App
Konfiguration</a></li>
<li><a href="#øvrige-scripts-i-pakken">Øvrige scripts i pakken</a></li>
</ul>
<hr />
<h2 id="pakkens-indhold">Pakkens indhold</h2>
<table>
<colgroup>
<col style="width: 38%" />
<col style="width: 61%" />
</colgroup>
<thead>
<tr>
<th>Fil</th>
<th>Formål</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Install.ps1</code></td>
<td>Kopierer RDP-filer til skrivebord(e), opretter selvsigneret
certifikat og signerer alle RDP-filer. Understøtter
<code>-AllUsers</code> switch.
</td>
</tr>
<tr>
<td><code>Detect.ps1</code></td>
<td>Tjekker at specifikke forventede .rdp-filer (defineret i
<code>$expectedFiles</code> array) eksisterer på skrivebord(e).
Understøtter <code>-AllUsers</code> switch.
</td>
</tr>
<tr>
<td><code>Uninstall.ps1</code></td>
<td>Fjerner RDP-filer fra skrivebord(e). Understøtter
<code>-AllUsers</code> switch.
</td>
</tr>
<tr>
<td><code>SignOnly.ps1</code></td>
<td>Signerer eksisterende RDP-filer på skrivebord(e) — ingen
filkopiering. Understøtter <code>-AllUsers</code> switch.</td>
</tr>
<tr>
<td><code>SignOnly_detect.ps1</code></td>
<td>Registrerer om certifikat er til stede og alle RDP-filer på
skrivebord(e) er signerede. Understøtter <code>-AllUsers</code>
switch.</td>
</tr>
<tr>
<td><code>Clearsigning.ps1</code></td>
<td>Fjerner signaturer fra RDP-filer og rydder op i certifikat og
registry (til oprydning/debug). Understøtter <code>-AllUsers</code>
switch.</td>
</tr>
<tr>
<td><code>sandbox.ps1</code></td>
<td>Kombineret install + detect script til lokal sandkasse-test.
Understøtter <code>-AllUsers</code> switch.</td>
</tr>
<tr>
<td><code>rdp-files\*.rdp</code></td>
<td>Kilde-RDP-filer der installeres på skrivebord(e)</td>
</tr>
</tbody>
</table>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="sådan-opsætter-du-detect.ps1">Sådan opsætter du Detect.ps1</h2>
<p>Før du uploader <code>Detect.ps1</code> til Intune som
registreringsregel, skal du åbne filen og udfylde
<code>$expectedFiles</code> array med de <code>.rdp</code> filnavne der
ligger i <code>.\\rdp-files\\</code>:
</p>
<div class="sourceCode" id="cb1">
<pre class="sourceCode powershell"><code class="sourceCode powershell"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="va">$expectedFiles</span> <span class="op">=</span> <span class="op">@(</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Server1.rdp&quot;</span><span class="op">,</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Server2.rdp&quot;</span><span class="op">,</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;DesktopApp.rdp&quot;</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="op">)</span></span></code></pre>
</div>
<p>Når scriptet kører: - Uden <code>-AllUsers</code>: tjekker at alle
filer i <code>$expectedFiles</code> findes på det offentlige skrivebord
(<code>C:\Users\Public\Desktop</code>) - Med <code>-AllUsers</code>:
tjekker alle filer i <code>$expectedFiles</code> på tværs af alle
brugeres skriveborde - Returnerer <code>exit 0</code> = installeret
(alle filer fundet) - Returnerer <code>exit 1</code> = ikke installeret
(en eller flere filer mangler)</p>
<blockquote>
<p><strong>Vigtigt:</strong> Husk at opdatere
<code>$expectedFiles</code> hver gang du tilføjer eller fjerner
<code>.rdp</code> filer i pakken, ellers vil detekteringen være
forkert.
</p>
</blockquote>
<hr />
<h2 id="intune-app-konfiguration">Intune App Konfiguration</h2>
<h3 id="program">Program</h3>
<ul>
<li><strong>Installationskommando:</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Install.ps1</code>
</li>
<li><strong>Installationskommando (alle brugeres skriveborde):</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Install.ps1 -AllUsers</code>
</li>
<li><strong>Afinstallationskommando:</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Uninstall.ps1</code>
</li>
<li><strong>Afinstallationskommando (alle brugeres
skriveborde):</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Uninstall.ps1 -AllUsers</code>
</li>
<li><strong>Installationsadfærd:</strong> System</li>
</ul>
<h3 id="registreringsregel">Registreringsregel</h3>
<p>Brug et brugerdefineret registreringsscript: -
<strong>Scriptfil:</strong> <code>Detect.ps1</code> - <strong>Kør script
som 32-bit proces på 64-bit klienter:</strong> Nej - <strong>Gennemtving
scriptsignaturkontrol:</strong> Nej
</p>
<p>Registreringslogik: - Uden <code>-AllUsers</code>: tjekker at alle
<code>.rdp</code>-filer er til stede på det offentlige skrivebord
(<code>C:\Users\Public\Desktop</code>) - Med <code>-AllUsers</code>:
tjekker alle brugeres skriveborde under <code>C:\Users\</code> -
Returnerer <code>exit 0</code> = installeret - Returnerer
<code>exit 1</code> = ikke installeret
</p>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="hvad-install.ps1-gør">Hvad Install.ps1 gør</h2>
<ol type="1">
<li>Finder målskrivebord(e) — offentligt skrivebord som standard, alle
brugeres skriveborde med <code>-AllUsers</code>. Med <code>-AllUsers</code>
søges 2 mapper ned så OneDrive-omdirigeret Desktop også fanges</li>
<li>Kopierer alle <code>.rdp</code>-filer fra <code>.\rdp-files\</code>
til de fundne skrivebord(e)</li>
<li>Søger efter eksisterende selvsigneret certifikat
(<code>CN=RDPSign</code>) i <code>Cert:\LocalMachine\My</code></li>
<li>Opretter et nyt selvsigneret kodesigneringscertifikat hvis intet
findes (gyldigt i 25 år, ikke-eksporterbart)</li>
<li>Tilføjer certifikatet til <code>Trusted Root</code> og
<code>Trusted Publishers</code> i den lokale maskines
certifikatstore
</li>
<li>Tilføjer certifikatets thumbprint til registry-nøglen
<code>TrustedCertThumbprints</code>
</li>
<li>Signerer alle <code>.rdp</code>-filer på skrivebord(e) med
<code>rdpsign.exe /sha256</code>
</li>
<li>Sætter <code>RedirectionWarningDialogVersion = 1</code> i registry
for at undertrykke RDP-advarselsdialoger</li>
</ol>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="allusers-switch">AllUsers Switch</h2>
<p>Alle scripts understøtter <code>-AllUsers</code> switchen. Som
standard — uden <code>-AllUsers</code> — køres alle scripts kun mod det
<strong>offentlige skrivebord</strong>
(<code>C:\Users\Public\Desktop</code>). Når <code>-AllUsers</code>
angives, søger scriptet i stedet på tværs af alle brugerprofiler under
<code>C:\Users\</code> (ekskl. <code>Public</code>/<code>Default</code>).
Der søges 2 mapper ned (<code>-Depth 2</code>) for at fange både standard
<code>Desktop</code> og OneDrive-omdirigeret <code>Desktop</code>.
</p>
<div class="sourceCode" id="cb2">
<pre
class="sourceCode powershell"><code class="sourceCode powershell"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Kun offentligt skrivebord (standard)</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="op">.</span>\Install<span class="op">.</span><span class="fu">ps1</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Alle brugeres skriveborde</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="op">.</span>\Install<span class="op">.</span><span class="fu">ps1</span> <span class="op">-</span>AllUsers</span></code></pre>
</div>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="registry-ændringer">Registry-ændringer</h2>
<table>
<colgroup>
<col style="width: 20%" />
<col style="width: 29%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr>
<th>Sti</th>
<th>Værdi</th>
<th>Type</th>
<th>Data</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services</code></td>
<td><code>TrustedCertThumbprints</code></td>
<td>String</td>
<td>Certifikatets thumbprint</td>
</tr>
<tr>
<td><code>HKLM\Software\Policies\Microsoft\Windows NT\Terminal Services\Client</code></td>
<td><code>RedirectionWarningDialogVersion</code></td>
<td>DWORD</td>
<td><code>1</code></td>
</tr>
</tbody>
</table>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="logning-og-fejlfinding">Logning og fejlfinding</h2>
<table>
<thead>
<tr>
<th>Script</th>
<th>Logfil</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Install.ps1</code></td>
<td><code>C:\Intune\DesktopShortcuts.log</code></td>
</tr>
<tr>
<td><code>Detect.ps1</code></td>
<td><code>C:\Intune\DesktopShortcuts.log</code></td>
</tr>
<tr>
<td><code>Uninstall.ps1</code></td>
<td><code>C:\Intune\DesktopShortcuts.log</code></td>
</tr>
<tr>
<td><code>SignOnly.ps1</code></td>
<td><code>C:\Intune\RDPSign.log</code></td>
</tr>
</tbody>
</table>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="signonly-intune-app-konfiguration">SignOnly Intune App
Konfiguration</h2>
<h3 id="program-1">Program</h3>
<ul>
<li><strong>Installationskommando:</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\SignOnly.ps1</code>
</li>
<li><strong>Installationskommando (alle brugeres skriveborde):</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\SignOnly.ps1 -AllUsers</code>
</li>
<li><strong>Afinstallationskommando:</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Clearsigning.ps1</code>
</li>
<li><strong>Afinstallationskommando (alle brugeres
skriveborde):</strong>
<code>powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File .\Clearsigning.ps1 -AllUsers</code>
</li>
<li><strong>Installationsadfærd:</strong> System</li>
</ul>
<h3 id="registreringsregel-1">Registreringsregel</h3>
<p>Brug et brugerdefineret registreringsscript: -
<strong>Scriptfil:</strong> <code>SignOnly_detect.ps1</code> -
<strong>Kør script som 32-bit proces på 64-bit klienter:</strong> Nej -
<strong>Gennemtving scriptsignaturkontrol:</strong> Nej
</p>
<p>Registreringslogik: - Tjekker at <code>CN=RDPSign</code>-certifikatet
findes i <code>My</code>, <code>Root</code> og
<code>TrustedPublisher</code> stores - Tjekker at thumbprint er til
stede i registry - Uden <code>-AllUsers</code>: tjekker at alle
<code>.rdp</code>-filer på det offentlige skrivebord er signerede - Med
<code>-AllUsers</code>: tjekker alle <code>.rdp</code>-filer på tværs af
alle brugeres skriveborde - Returnerer <code>exit 0</code> +
<code>"Detected"</code> = installeret - Returnerer <code>exit 1</code> =
ikke installeret
</p>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>
<hr />
<h2 id="øvrige-scripts-i-pakken">Øvrige scripts i pakken</h2>
<blockquote>
<p><strong>Bemærk:</strong> Alle PowerShell-scripts er pakket ind i
samme IntuneWin-pakke. Det betyder at man altid kan kalde på et
vilkårligt script direkte fra Intune eller manuelt, f.eks.:</p>
<div class="sourceCode" id="cb3">
<pre
class="sourceCode powershell"><code class="sourceCode powershell"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\Install<span class="op">.</span><span class="fu">ps1</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\Install<span class="op">.</span><span class="fu">ps1</span> <span class="op">-</span>AllUsers</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\SignOnly<span class="op">.</span><span class="fu">ps1</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\SignOnly<span class="op">.</span><span class="fu">ps1</span> <span class="op">-</span>AllUsers</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\Clearsigning<span class="op">.</span><span class="fu">ps1</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>powershell<span class="op">.</span><span class="fu">exe</span> <span class="op">-</span>ExecutionPolicy Bypass <span class="op">-</span>NoProfile <span class="op">-</span>WindowStyle Hidden <span class="op">-</span>File <span class="op">.</span>\Clearsigning<span class="op">.</span><span class="fu">ps1</span> <span class="op">-</span>AllUsers</span></code></pre>
</div>
<p>osv. for alle scripts i pakken.</p>
</blockquote>
<h3 id="signonly.ps1"><code>SignOnly.ps1</code></h3>
<p>Signerer alle eksisterende <code>.rdp</code>-filer på skrivebord(e)
uden at kopiere filer. Nyttigt til gensignering efter en opdatering
eller hvis filer allerede er installeret. Kør som administrator.
Understøtter <code>-AllUsers</code> switch.</p>
<h3 id="signonly_detect.ps1"><code>SignOnly_detect.ps1</code></h3>
<p>Registreringsscript til brug med <code>SignOnly.ps1</code> som
Intune-pakke. Tjekker: - Certifikat findes i <code>My</code>,
<code>Root</code> og <code>TrustedPublisher</code> stores - Thumbprint
er til stede i registry - Alle <code>.rdp</code>-filer på skrivebord(e)
indeholder en gyldig signatur
</p>
<p>Understøtter <code>-AllUsers</code> switch.</p>
<h3 id="clearsigning.ps1"><code>Clearsigning.ps1</code></h3>
<p>Fjerner alle signeringsartefakter. Nyttigt til test eller oprydning.
Kør som administrator. Understøtter <code>-AllUsers</code> switch. -
Fjerner <code>signscope</code>- og <code>signature</code>-linjer fra
alle <code>.rdp</code>-filer på skrivebord(e) - Fjerner
<code>CN=RDPSign</code>-certifikatet fra <code>My</code>,
<code>Root</code> og <code>TrustedPublisher</code> stores - Fjerner
<code>TrustedCertThumbprints</code> fra registry - Fjerner
<code>RedirectionWarningDialogVersion</code> fra registry
</p>
<h3 id="sandbox.ps1"><code>sandbox.ps1</code></h3>
<p>Kombinerer install og detect i ét script til lokal sandkasse-test.
Understøtter <code>-AllUsers</code> switch. Kør fra mappen der
indeholder <code>rdp-files\</code> som administrator. Output skrives til
både konsollen og <code>C:\Intune\DesktopShortcuts.log</code>.</p>
<p><a href="#rdp---intunewin-pakke">↑ Tilbage til toppen</a></p>