UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

326 lines (324 loc) 10.6 kB
import { MediaConversion, MediaConversionBase } from '../../data/units'; /** * Windows Operating Systems */ export var WindowsOperatingSystem; (function (WindowsOperatingSystem) { WindowsOperatingSystem[WindowsOperatingSystem["Unknown"] = 0] = "Unknown"; WindowsOperatingSystem[WindowsOperatingSystem["Legacy"] = 1] = "Legacy"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsVista"] = 2] = "WindowsVista"; WindowsOperatingSystem[WindowsOperatingSystem["Windows7"] = 3] = "Windows7"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2008"] = 4] = "WindowsServer2008"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2008R2"] = 5] = "WindowsServer2008R2"; WindowsOperatingSystem[WindowsOperatingSystem["Windows8"] = 6] = "Windows8"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2012"] = 7] = "WindowsServer2012"; WindowsOperatingSystem[WindowsOperatingSystem["Windows8Point1"] = 8] = "Windows8Point1"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2012R2"] = 9] = "WindowsServer2012R2"; WindowsOperatingSystem[WindowsOperatingSystem["Windows10"] = 10] = "Windows10"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2016"] = 11] = "WindowsServer2016"; WindowsOperatingSystem[WindowsOperatingSystem["WindowsServer2019"] = 12] = "WindowsServer2019"; })(WindowsOperatingSystem || (WindowsOperatingSystem = {})); /** * Windows Product Types */ export var WindowsProductType; (function (WindowsProductType) { WindowsProductType[WindowsProductType["Workstation"] = 1] = "Workstation"; WindowsProductType[WindowsProductType["DomainController"] = 2] = "DomainController"; WindowsProductType[WindowsProductType["Server"] = 3] = "Server"; })(WindowsProductType || (WindowsProductType = {})); /** * Server Inventory class. */ export class ServerInventory { serverName; static nanoDisplayFormat = '{0} Nano'; static server19PreviewBuildNumber = 17623; /* * OperatingSystemSKU: from https://msdn.microsoft.com/en-us/library/aa394239(v=vs.85).aspx * PRODUCT_DATACENTER_NANO_SERVER (143) * Windows Server Datacenter Edition (Nano Server installation) * PRODUCT_STANDARD_NANO_SERVER (144) * Windows Server Standard Edition (Nano Server installation) */ static nanoServerSkus = [143, 144]; /** * The name of server. (CSName/OperatingSystem) */ name; /** * The domain name of server. (Domain/ComputerSystem) */ domainName; /** * The workgroup name of server if any. (Workgroup/ComputerSystem) */ workgroupName; /** * The FQDN of server if any. (ComputerSystem) */ fullyQualifiedDomainName; /** * The FQDN of server if any. (ComputerSystem) Not lower cased. */ fullyQualifiedDomainNameRaw; /** * The hostname of computer which was configured on the computer. */ hostname; /** * The hostname of computer which was configured on the computer. Not lower cased. */ hostnameRaw; /** * The NetBios name which might be trimmed by 15 characters. */ netBios; /** * The IP address list. */ addressList; /** * The operating system name of server. (Caption/OperatingSystem) */ operatingSystemName; /** * The operating system name of server. (SKU/OperatingSystem) */ operatingSystemSKU; /** * The operating system version of server. (Version/OperatingSystem) */ operatingSystemVersion; /** * The total size of physical memory. */ totalPhysicalMemory; /** * The domain role. */ domainRole; /** * The windows product type. */ productType; /** * The computer manufacturer. */ computerManufacturer; /** * The computer model. */ computerModel; /** * The number of logical processors. */ totalLogicalProcessors; /** * Indicating if the server has ManagementTools namespace to support TaskManager provider. */ isManagementToolsAvailable; /** * Indicating if the computer has ServerManager namespace to support ServerManager provider. */ isServerManagerAvailable; /** * Whether or not Windows Management Framework v5.0 or higher is installed. */ isWmfInstalled; /** * Indicating if the server node is a part of Microsoft Cluster. */ isCluster; /** * The FQDN of Microsoft Cluster if it's a part of Microsoft Cluster. */ clusterFqdn; /** * Indicating if current user is a member of administrators group. */ isAdministrator; /** * Indicates if the node has S2D enabled */ isS2dEnabled; /** * Indicates if the node has Britannica enabled */ isBritannicaEnabled; /** * Indicates if the hyper-v role is installed */ isHyperVRoleInstalled; /** * Indicates if the hyper-v powershell feature is installed */ isHyperVPowershellInstalled; /** * Indicates if CredSSP is enabled. */ isCredSSPEnabled; /** * Indicating if remote app enabled. */ isRemoteAppEnabled; /** * SMBIOS Data */ smbiosData; /** * The system lockdown policy enforcement mode. */ systemLockdownPolicy; /** * Type of operating system value */ osType; /** * Product name that a manufacturer gives to a computer */ model; /** * Last reboot time */ lastBootUpTime; /** * The status of the azure arc in the server * i.e connectioned, disconnected etc */ azureArcStatus; /* * Operating system serial number */ osSerialNumber; /** * The operating system build number */ buildNumber; /** * The operating system update build revision */ updateBuildRevision; /** * The operating system display version eg: 22H2 */ operatingSystemDisplayVersion; /** * Indicating if the server is HCI. */ isHciServer; /** * Initializes a new instance of the ServerInventory Class. * * @param serverName the server name to query. * @param data the server inventory recovered data. */ constructor(serverName, data) { this.serverName = serverName; if (data) { Object.assign(this, data); } } /** * Gets the sku number indicating whether the computer is Nano server. * * @return boolean true if nano */ get isNano() { // given sku number is in nanoServerSkus array? return ServerInventory.nanoServerSkus.indexOf(this.operatingSystemSKU) > -1; } /** * Gets a value indicating if this is a windows server * * @return boolean true if this is a server */ get isServer() { return this.productType === WindowsProductType.Server; } /** * Gets a value indicating if this is a windows client * * @return boolean true if this is a client */ get isClient() { return this.productType === WindowsProductType.Workstation; } /** * Indicates whether the computer is domain controller or not. * * @return boolean true if domain controller */ get isDomainController() { // As per https://msdn.microsoft.com/en-us/library/windows/desktop/aa394102(v=vs.85) // domainRole of 4 or 5 means it's a domain controller. return (this.domainRole === 4 || this.domainRole === 5); } /** * Gets the display name of operating system. */ get operatingSystemDisplayName() { return this.isNano ? ServerInventory.nanoDisplayFormat.format(this.operatingSystemName) : this.operatingSystemName; } /** * Gets the display name of total physical memory. */ get totalPhysicalMemoryDisplayName() { return MediaConversion.getConvertedValue(this.totalPhysicalMemory, MediaConversionBase.Binary); } /** * Gets the operating system enumb of the machine * see: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx for operating system version mapping. */ get operatingSystem() { if (!this.operatingSystemVersion) { return WindowsOperatingSystem.Unknown; } // windows 10, server 2016, and server 2019 // report anything newer as one of these options. if (this.operatingSystemVersion.indexOf('.') > 1) { // since . is more than 2 digits from the start of the screen we are going to assume its '10.', '11.', etc... if (this.isServer) { if (+this.operatingSystemVersion.split('.').last() >= ServerInventory.server19PreviewBuildNumber) { // 17623 first insiders preview of 2019 return WindowsOperatingSystem.WindowsServer2019; } else { // 14393 official release version of 2016 // fall back to 2016 for versions between 14393 and 17623 return WindowsOperatingSystem.WindowsServer2016; } } else { return WindowsOperatingSystem.Windows10; } } // windows 8.1 and server 2012r2 if (this.operatingSystemVersion.startsWith('6.3')) { return this.isServer ? WindowsOperatingSystem.WindowsServer2012R2 : WindowsOperatingSystem.Windows8Point1; } // windows 8 and server 2012 if (this.operatingSystemVersion.startsWith('6.2')) { return this.isServer ? WindowsOperatingSystem.WindowsServer2012 : WindowsOperatingSystem.Windows8; } // windows 7 and server 2008 R2 if (this.operatingSystemVersion.startsWith('6.1')) { return this.isServer ? WindowsOperatingSystem.WindowsServer2008R2 : WindowsOperatingSystem.Windows7; } // windows vista and server 2008 if (this.operatingSystemVersion.startsWith('6.0')) { return this.isServer ? WindowsOperatingSystem.WindowsServer2008 : WindowsOperatingSystem.WindowsVista; } // assume a legacy os that somehow was able to run powershell.(unlikely) return WindowsOperatingSystem.Legacy; } } //# sourceMappingURL=server-inventory.js.map