📄 JScript (WSH)

Get Network Login Profiles Report (JScript)

Queries Win32_NetworkLoginProfile via WMI and prints Network Login Profiles to the console — JScript, VBScript's WSH sibling language.

By WindowsScripting.com · 1 KB
GetNetworkLoginProfileReport.js
// ============================================================
// GetNetworkLoginProfileReport.js
//
// Reports Network Login Profiles via WMI (Win32_NetworkLoginProfile). JScript (Windows Script Host) —
// VBScript's sibling language, run the same way via cscript/wscript.
//
// Usage: cscript GetNetworkLoginProfileReport.js
// ============================================================

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");
var colItems = objWMIService.ExecQuery("SELECT Name, LastLogon, NumberOfLogons FROM Win32_NetworkLoginProfile");

var e = new Enumerator(colItems);
var output = "";
var count = 0;

for (; !e.atEnd(); e.moveNext()) {
    var item = e.item();
    output += "Name: " + item.Name + "\n";
    output += "LastLogon: " + item.LastLogon + "\n";
    output += "NumberOfLogons: " + item.NumberOfLogons + "\n";
    output += new Array(41).join("-") + "\n";
    count++;
}

if (count === 0) {
    WScript.Echo("No Network Login Profiles found.");
} else {
    WScript.Echo(output);
}