Skip to content

Commit

Permalink
[SSDK-20773] PowerShell Script Documentation for Windows.
Browse files Browse the repository at this point in the history
Document all the PowerShell scripts created for Windows SDK and CoreScanner.
  • Loading branch information
erangazebra committed Jan 22, 2025
1 parent 390e468 commit c527009
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 61 deletions.
18 changes: 16 additions & 2 deletions dcs/scanners/dcs_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
Description : DCS content specific JS.
Author : Eranga Tennakoon - GQCD86
Release Notes :
01/22/2025 - Code snippets copy and PowerShell file download support added.
05/12/2024 - Initial document. Tab control support added
*/

/*
Manage tabs on DCS Scanner home page (dcs/scanners/index.html).
Make sure to display only on tab content at time.
*/
function openTab(contentId) {
var tabContainer = event.currentTarget.closest('.tab-container');
var tabs = tabContainer.querySelectorAll('.tab');
Expand All @@ -18,6 +23,10 @@ function openTab(contentId) {
document.getElementById(contentId).classList.add('active');
}

/*
Copy the code snippet to clipboard. Button animation implemented between 'Copy' and 'Copied'.
Time intervals can be adjusted as needed. Refer to the comments below.
*/
function copyCode(button) {
const code = document.getElementById('code-snippet').innerText;
navigator.clipboard.writeText(code).then(() => {
Expand All @@ -30,16 +39,21 @@ function copyCode(button) {
});
}


/*
Create the download file using the code block specified in <code></code> tags.
Using this I've avoid keeping the physical files in the server.
*/
function downloadFile(filename) {
const code = document.getElementById('code-snippet').innerText;
const blob = new Blob([code], { type: 'text/plain' });
const url = URL.createObjectURL(blob);

const a = document.createElement('a');
a.href = url;
a.download = filename; // Use the passed filename
a.download = filename; // Use the passed filename, as the name of the download file.
document.body.appendChild(a);
a.click();

document.body.removeChild(a);
URL.revokeObjectURL(url);
}
56 changes: 0 additions & 56 deletions dcs/scanners/downloads/CoreScanner_AssetInfo.ps1

This file was deleted.

5 changes: 2 additions & 3 deletions dcs/scanners/sdk-windows/powershell-scripts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h3 id="powershell-scripts-asset-info" class="anchor"><a class="heading-anchor"

<div class="code-container">
<button class="button copy-button" onclick="copyCode(this)">Copy</button>
<button class="button download-button" onclick="downloadFile('../../downloads/CoreScanner_AssetInfo.ps1')">
<button class="button download-button" onclick="downloadFile('CoreScanner_AssetInfo.ps1')">
<img src="../../images/common/download.png">
</button>
<pre class="prettyprint">
Expand All @@ -163,8 +163,7 @@ <h3 id="powershell-scripts-asset-info" class="anchor"><a class="heading-anchor"
# Support PSVersion 5+.
# Copyright : ©2025 Zebra Technologies Corp. and/or its affiliates.

# Log everything, file will create in the script execution folder.
# Comment the following line if logging is not required.
# Enable logging.
Start-Transcript -Append -Path $PSScriptRoot"\CoreScanner_AssetInfo.log.txt"

# Process GetScanners out XML and list the asset information
Expand Down

0 comments on commit c527009

Please sign in to comment.