### Install and Run MeshCommander via NPM Source: https://github.com/ylianst/meshcommander/blob/master/readme.md Use these commands to install the package via Node Package Manager and start the local web server on port 3000. ```bash mkdir meshcommander cd meshcommander npm install meshcommander node node_modules\meshcommander ``` -------------------------------- ### Start Script Block Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Initializes the script execution process. ```MeshCommander Script print "Script Started" ``` -------------------------------- ### Get AMT Boot Settings Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the current AMT boot settings and prints them to the console. ```MeshCommander Script split ws_general_query "*AMT_BootSettingData" wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set bootoptions wsman_answer.AMT_BootSettingData.response print bootoptions set AMT_BootSettingData jump :error-%%%~%%% wsman_result "!=" 200 jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set ws_general_query set wsman_answer set wsman_result set wsman_result_str #set bootoptions ``` -------------------------------- ### Set AMT Boot Settings Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures next boot parameters such as BIOS setup and Serial-over-LAN status. ```MeshCommander Script split ws_general_query "*AMT_BootSettingData" wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set bootoptions wsman_answer.AMT_BootSettingData.response set bootoptions.BIOSSetup "%%%bootBiosSetup%%%" set bootoptions.UseSOL "%%%bootSerialOverLan%%%" wsput "AMT_BootSettingData" bootoptions set AMT_BootSettingData jump :error-%%%~%%% wsman_result "!=" 200 jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set ws_general_query set wsman_answer set wsman_result set wsman_result_str #set bootoptions ``` -------------------------------- ### Start MeshCommander using MeshCMD Source: https://github.com/ylianst/meshcommander/blob/master/readme.md Execute this command to launch the MeshCommander web server when using the MeshCMD command-line tool. ```bash meshcmd meshcommander ``` -------------------------------- ### Get Intel AMT Provisioning Mode Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the current Intel AMT provisioning mode and prints it to the console. ```scriptblock jsonparse provModeHmap "%7B%221%22:%22Admin%20Control%20Mode%20(ACM)%22,%222%22:%22Reserved1%22,%223%22:%22Client%20Control%20Mode%20(CCM)%22,%224%22:%22Reserved2%22%7D" split ws_general_query "*AMT_SetupAndConfigurationService" wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set key wsman_answer.AMT_SetupAndConfigurationService.response.ProvisioningMode set AmtProvMode provModeHmap.{key} print "Intel AMT Provisioning Mode: {AmtProvMode}" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set ws_general_query set wsman_answer set wsman_result set wsman_result_str set provModeHmap set key ``` -------------------------------- ### Get Provisioning State Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the current Provisioning State of Intel AMT, prints it to the console, and stores it in the AmtProvState variable. ```MeshCommander Script jsonparse provStateHmap "%7B%220%22:%22Pre%22,%221%22:%22In%22,%222%22:%22Post%22%7D" split ws_general_query "*AMT_SetupAndConfigurationService" wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set key wsman_answer.AMT_SetupAndConfigurationService.response.ProvisioningState set AmtProvState provStateHmap.{key} add AmtProvState AmtProvState "-Provisioning" print "Intel AMT Provisioning State: {AmtProvState}" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set ws_general_query set wsman_answer set wsman_result set wsman_result_str set provStateHmap set key ``` -------------------------------- ### Get Intel AMT Version Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the Intel AMT release version, prints it to the console, and stores it in the AmtCoreVersion variable. ```MeshCommander Script split ws_general_query "CIM_SoftwareIdentity" wsbatchenum "wsman_answer" ws_general_query set i 0 set arr wsman_answer.CIM_SoftwareIdentity.responses length arr_len arr :loop-%%%~%%% set curInstanceId arr.{i}.InstanceID jump :AmtCoreVersionFound-%%%~%%% curInstanceId "=" "AMT FW Core Version" add i i 1 jump :loop-%%%~%%% i "<" arr_len print "Error: Intel AMT version was not found" jump :end-%%%~%%% :AmtCoreVersionFound-%%%~%%% set AmtCoreVersion arr.{i}.VersionString print "Intel AMT version: {AmtCoreVersion}" :end-%%%~%%% set arr set arr_len set curInstanceId set i set ws_general_query set wsman_answer set wsman_result ``` -------------------------------- ### Get Platform Type Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the platform type of the target, prints it to the console, and stores it in the PlatformType variable. ```MeshCommander Script jsonparse sysTypeHmap "%7B%2232%22:%22Desktop%22,%2233%22:%22Notebook%22%7D" split ws_general_query "CIM_ComputerSystem" wsbatchenum "wsman_answer" ws_general_query set i -1 jump :error-%%%~%%% wsman_result "!=" 200 getitem i wsman_answer.CIM_ComputerSystem.responses "ElementName" "Managed System" jump :amtCoreError-%%%~%%% i "<" 0 set i wsman_answer.CIM_ComputerSystem.responses.{i}.Dedicated set PlatformType sysTypeHmap.{i} print "Platform Type: {PlatformType}" jump :end-%%%~%%% :amtCoreError-%%%~%%% print "Error: couldn't find CIM_ComputerSystem.ElementName = %22Managed System%22" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set i set ws_general_query set wsman_answer set wsman_result set wsman_result_str set sysTypeHmap ``` -------------------------------- ### Get Intel AMT UUID Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Retrieves the Intel AMT UUID, prints it to the console, and stores it in the AmtUuid variable. ```scriptblock split ws_general_query "CIM_ComputerSystem" wsbatchenum "wsman_answer" ws_general_query set i -1 jump :error-%%%~%%% wsman_result "!=" 200 getitem i wsman_answer.CIM_ComputerSystem.responses "ElementName" "Managed System" jump :amtCoreError-%%%~%%% i "<" 0 set AmtUuid wsman_answer.CIM_ComputerSystem.responses.{i}.OtherIdentifyingInfo print "Intel AMT UUID: {AmtUuid}" jump :end-%%%~%%% :amtCoreError-%%%~%%% print "Error: couldn't find CIM_ComputerSystem.ElementName = %22Managed System%22" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set i set ws_general_query set wsman_answer set wsman_result ``` -------------------------------- ### Set Hostname and Domain Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Updates the hostname and domain name settings for Intel AMT. ```scriptblock split ws_general_query "*AMT_GeneralSettings" , wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set wsman_answer.AMT_GeneralSettings.response.HostName "%%%hostname%%%" set wsman_answer.AMT_GeneralSettings.response.DomainName "%%%domainname%%%" wsput "AMT_GeneralSettings" wsman_answer.AMT_GeneralSettings.response jump :error-%%%~%%% wsman_result "!=" 200 set PullSystemStatus "1" jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Jump to Label Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Redirects script execution to a specified label. ```text jump :%%%label%%% ``` -------------------------------- ### Retrieve Intel AMT FQDN Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Fetches the host and domain name from AMT_GeneralSettings to construct and store the full FQDN. ```MeshCommander Script split ws_general_query "*AMT_GeneralSettings" wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set AmtFqdn wsman_answer.AMT_GeneralSettings.response.HostName add AmtFqdn AmtFqdn "." add AmtFqdn AmtFqdn wsman_answer.AMT_GeneralSettings.response.DomainName print "Intel AMT FQDN: {AmtFqdn}" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set ws_general_query set wsman_answer set wsman_result ``` -------------------------------- ### Configure Intel AMT Environment Detection Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Validates and sets environment detection strings and IPv6 local prefixes for Intel AMT. Requires input variables for detection strings and IPv6 prefixes, with a maximum limit of 5 entries each. ```MeshCommander Script # *** Validate user input *** print "Parsing block parameters" jump :EMPTY_DETECTIONSTR-%%%~%%% "%%%DetectionStrings%%%" "=" "" split arrDetectionStrings "%%%DetectionStrings%%%" "," split arrDetectionIPv6LocalPrefixes "%%%DetectionIPv6LocalPrefixes%%%" "," print "Setting Environment Detection" split ws_general_query "*AMT_EnvironmentDetectionSettingData" "," wsbatchenum "wsman_answer" ws_general_query set envDetectionInstance wsman_answer.AMT_EnvironmentDetectionSettingData.response jump :DetectionStringsDefined-%%%~%%% envDetectionInstance.DetectionStrings "!=" set envDetectionInstance.DetectionStrings arrDetectionStrings jump :SET_IPV6_PREFIX-%%%~%%% :DetectionStringsDefined-%%%~%%% add arrDetectionStrings "," arrDetectionStrings add envDetectionInstance.DetectionStrings envDetectionInstance.DetectionStrings arrDetectionStrings maketoarray envDetectionInstance.DetectionStrings envDetectionInstance.DetectionStrings length arrDetectionStringsLen envDetectionInstance.DetectionStrings jump :INVALID_LEN_DetectionStrings-%%%~%%% arrDetectionStringsLen ">" "5" :SET_IPV6_PREFIX-%%%~%%% jump :IPv6StringsDefined-%%%~%%% envDetectionInstance.DetectionIPv6LocalPrefixes "!=" jump :EMPTY_IPV6PRFX "%%%DetectionIPv6LocalPrefixes%%%" "=" "" set envDetectionInstance.DetectionIPv6LocalPrefixes arrDetectionIPv6LocalPrefixes jump :CALL_WSPUT-%%%~%%% :IPv6StringsDefined-%%%~%%% add arrDetectionIPv6LocalPrefixes "," arrDetectionIPv6LocalPrefixes add envDetectionInstance.DetectionIPv6LocalPrefixes envDetectionInstance.DetectionIPv6LocalPrefixes arrDetectionIPv6LocalPrefixes maketoarray envDetectionInstance.DetectionIPv6LocalPrefixes envDetectionInstance.DetectionIPv6LocalPrefixes :EMPTY_IPV6PRFX length arrDetectionIPv6LocalPrefixesLen envDetectionInstance.DetectionIPv6LocalPrefixes jump :INVALID_LEN_DetectionIPv6LocalPrefixes-%%%~%%% arrDetectionIPv6LocalPrefixesLen ">" "5" :CALL_WSPUT-%%%~%%% wsput "AMT_EnvironmentDetectionSettingData" envDetectionInstance jump :error-%%%~%%% wsman_result "!=" 200 print "Environment Detection set successfully" jump :end-%%%~%%% :error-%%%~%%% print "ERROR: WSMAN call failed: {wsman_result_str}" jump :end-%%%~%%% :INVALID_LEN_DetectionStrings-%%%~%%% print "ERROR: detection strings count must be at most 5" jump :end-%%%~%%% :INVALID_LEN_DetectionIPv6LocalPrefixes-%%%~%%% print "ERROR: IPv6 prefixes count must be at most 5" jump :end-%%%~%%% :EMPTY_DETECTIONSTR-%%%~%%% print "ERROR: %22Detection Strings%22 field cannot be empty, aborting operation..." :end-%%%~%%% set PullRemoteAccess "1" set AMT_EnvironmentDetectionSettingData set arrDetectionIPv6LocalPrefixes set arrDetectionStrings set envDetectionInstance set ws_general_query set wsman_answer set wsman_result ``` -------------------------------- ### Print to Console Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Outputs a string to the console. Use URL escaping for special characters and {x} to reference variable x. ```text print "%%%printstring%%%" ``` -------------------------------- ### Print User Consent Mode Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Displays the current Intel AMT user consent mode configuration. ```scriptblock jsonparse OptInStateEnum "%7B%220%22:%22Not Required%22,%221%22:%22Required for KVM only%22,%224294967295%22:%22Always Required%22%7D" split ws_optIn_query "*IPS_OptInService" , wsbatchenum "wsman_answer" ws_optIn_query jump :error-%%%~%%% wsman_result "!=" 200 print "User Consent mode: {OptInStateEnum.{wsman_answer.IPS_OptInService.response.OptInRequired}}" jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Add Kerberos User Account Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Script to add a new Kerberos user account to Intel AMT using a SID byte array. ```MeshCommander Script # Set kerberos sid value as a byte array string set KerberosUserString "%%%sid%%%" GetSidByteArray x KerberosUserString btoa KerberosUserSid x jsonparse wsargs "%7B%22KerberosUserSid%22:%22{KerberosUserSid}%22,%22AccessPermission%22:%%%accessPermission%%%,%22Realms%22:[%%%realms%%%]%7D" wsexec "AMT_AuthorizationService" "AddUserAclEntryEx" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Account {KerberosUserString} return value: {AMT_AuthorizationService.Body.ReturnValueStr}" set PullUserInfo 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Add Digest User Account Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Creates a new digest user account in Intel AMT by fetching the digest realm and executing a WSMAN command. ```MeshCommander Script # Get the DigestRealm jump :SkipDigestRealm-%%%~%%% DigestRealm "!=" print "Fetching digest realm..." split ws_general_query "*AMT_GeneralSettings" , wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set DigestRealm wsman_answer.AMT_GeneralSettings.response.DigestRealm :SkipDigestRealm-%%%~%%% # Create account set AccountName "%%%name%%%" set AccountPass "%%%password%%%" set digest "{AccountName}:{DigestRealm}:{AccountPass}" md5 digestmd5 digest btoa digestmd5 digestmd5 jsonparse wsargs "%7B %22DigestUsername%22:%22{AccountName}%22, %22DigestPassword%22:%22{digestmd5}%22, %22AccessPermission%22:%%%accessPermission%%%, %22Realms%22:[%%%realms%%%] %7D" wsexec "AMT_AuthorizationService" "AddUserAclEntryEx" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Account {AccountName} create: {AMT_AuthorizationService.Body.ReturnValueStr}" set PullUserInfo 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Execute Power State Change Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Performs a power state change on a managed system using WSMAN. Requires a valid power action code. ```MeshCommander Script set ManagedElementXml "%3CAddress xmlns=\%22http://schemas.xmlsoap.org/ws/2004/08/addressing\%22%3Ehttp://schemas.xmlsoap.org/ws/2004/08/addressing%3C/Address%3E%3CReferenceParameters xmlns=\%22http://schemas.xmlsoap.org/ws/2004/08/addressing\%22%3E%3CResourceURI xmlns=\%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\%22%3Ehttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem%3C/ResourceURI%3E%3CSelectorSet xmlns=\%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd\%22%3E%3CSelector Name=\%22CreationClassName\%22%3ECIM_ComputerSystem%3C/Selector%3E%3CSelector Name=\%22Name\%22%3EManagedSystem%3C/Selector%3E%3C/SelectorSet%3E%3C/ReferenceParameters%3E" jsonparse wsargs "%7B %22PowerState%22:%22%%%powerAction%%%%22, %22ManagedElement%22:%22{ManagedElementXml}%22 %7D" set ManagedElementXml wsexec "CIM_PowerManagementService" "RequestPowerStateChange" wsargs set wsargs jump :error-%%%~%%% wsman_result "!=" 200 set PullSystemStatus "1" print "Power action completed" jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Configure Intel AMT KVM State Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Updates the KVM state for Intel AMT using the CIM_KVMRedirectionSAP class. ```MeshCommander Script jsonparse wsargs "%7B %22RequestedState%22:%22%%%kvmEnabled%%%%22 %7D" wsexec "CIM_KVMRedirectionSAP" "RequestStateChange" wsargs jump :error-%%%~%%% wsman_result "!=" 200 set PullSystemStatus "1" jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Set User Consent Mode Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures the IPS_OptInService to define user consent requirements for Intel AMT. ```MeshCommander Script split ws_optIn_query "*IPS_OptInService" , wsbatchenum "wsman_answer" ws_optIn_query jump :error-%%%~%%% wsman_result "!=" 200 set wsman_answer.IPS_OptInService.response.OptInRequired %%%consentMode%%% wsput "IPS_OptInService" wsman_answer.IPS_OptInService.response jump :error-%%%~%%% wsman_result "!=" 200 set PullSystemStatus 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Computer List JSON Format Source: https://github.com/ylianst/meshcommander/blob/master/switches.md The format for the file used with the -list switch to load multiple computers into MeshCommander. ```json { "computers": [ { "name": "FriendlyName", "host": "hostname", "user": "admin", "pass": "password1", "tls": 0 }, { "host": "hostname1", "user": "admin", "pass": "password2", "tls": 1 }, { "host": "hostname1", "user": "*", "pass": "", "tls": 1 } ] } ``` -------------------------------- ### Add MPS Server via FQDN and User Credentials Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Adds a new CIRA server (MPS) using the server's hostname and authenticates via username and password. ```MeshCommander Script # Set method parameters jsonparse wsargs "%7B%22AccessInfo%22:%22%%%FQDN%%%%22,%22InfoFormat%22:201,%22Port%22:%%%Port%%%,%22AuthMethod%22:2,%22Username%22:%22%%%username%%%%22,%22Password%22:%22%%%password%%%%22%7D" # Execute call to AddMpServer wsexec "AMT_RemoteAccessService" "AddMpServer" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Management Prescence Server (MPS) successfully added to the Intel(R) AMT Subsystem" set PullRemoteAccess 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set AMT_RemoteAccessService set certHandle set curSubject set i set pos set ws_general_query set wsargs set wsman_answer set wsman_result set wsman_result_str set certInstanceId set wsman_ans_length ``` -------------------------------- ### Set User Initiation State Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Enables or disables the Intel AMT Client Initiation Remote Access (CIRA) connection feature for local or user-initiated access. ```scriptblock # Set method parameters jsonparse wsargs "%7B%22RequestedState%22:%22%%%ReqState%%%%22%7D" jsonparse EnumState "%7B%2232768%22:%22Disabled%22,%2232769%22:%22BIOS Enabled%22,%2232770%22:%22OS enable%22,%2232771%22:%22BIOS & OS Enabed%22%7D" # Execute call to change the state wsexec "AMT_UserInitiatedConnectionService" "RequestStateChange" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "SUCCESS: Remote Access user interfaces set to: {EnumState.%%%ReqState%%%}" set PullRemoteAccess 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set wsargs set wsman_result set wsman_result_str set EnumState set AMT_UserInitiatedConnectionService ``` -------------------------------- ### Basic Variable and Flow Control Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Fundamental operations for variable arithmetic, connection management, and script flow control. ```MeshCommander Script add %%%var%%% %%%var%%% %%%value%%% ``` ```MeshCommander Script Disconnect ``` ```MeshCommander Script :%%%label%%% ``` -------------------------------- ### Issue Untrusted Certificate Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Generates a key pair and signs a certificate with an untrusted dummy root for Intel AMT. ```MeshCommander Script jump :certificateSupport-%%%~%%% _certificates "=" 1 print "ERROR: No certificate support, this script block can't run in thei environment" jump :end2-%%%~%%% :certificateSupport-%%%~%%% set CommonName "%%%CommonName%%%"" length x CommonName jump :skipSetCommonName-%%%~%%% x "!=" 0 split ws_general_query "*AMT_GeneralSettings" , wsbatchenum "wsman_answer" ws_general_query jump :error-%%%~%%% wsman_result "!=" 200 set CommonName "{wsman_answer.AMT_GeneralSettings.response.HostName}" length x CommonName jump :skipSetDomainName-%%%~%%% x "=" 0 set CommonName "{wsman_answer.AMT_GeneralSettings.response.HostName}.{wsman_answer.AMT_GeneralSettings.response.DomainName}" :skipSetDomainName-%%%~%%% :skipSetCommonName-%%%~%%% jsonparse certattributes "%7B %22CN%22:%22{CommonName}%22, %22O%22:%22%%%Organization%%%%22, %22ST%22:%22%%%StateProvince%%%%22, %22C%22:%22%%%Country%%%%22 %7D" jsonparse wsargs "%7B %22KeyAlgorithm%22:%220%22, %22KeyLength%22:%222048%22 %7D" wsexec "AMT_PublicKeyManagementService" "GenerateKeyPair" wsargs jump :error-%%%~%%% wsman_result "!=" 200 set selector AMT_PublicKeyManagementService.Body.KeyPair.ReferenceParameters.SelectorSet.Selector.Value split ws_query "AMT_PublicPrivateKeyPair" , wsbatchenum "wsman_answer" ws_query jump :error-%%%~%%% wsman_result "!=" 200 getitem i wsman_answer.AMT_PublicPrivateKeyPair.responses "InstanceID" selector set DERKey wsman_answer.AMT_PublicPrivateKeyPair.responses.{i}.DERKey signwithdummyca DERKey certattributes jsonparse wsargs "%7B %22CertificateBlob%22:%22{signed_cert}%22 %7D" wsexec "AMT_PublicKeyManagementService" "AddCertificate" wsargs jump :error-%%%~%%% wsman_result "!=" 200 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set PullCertificates 1 :end2-%%%~%%% set i set x set wsman_answer set selector set AMT_PublicKeyManagementService set ws_query set AMT_PublicKeyManagementService set DERKey set wsargs ``` -------------------------------- ### Add MPS Server via Certificate Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures a new CIRA server (MPS) by searching for a specific certificate common name and executing the AddMpServer method. ```MeshCommander Script # Get the input from user for the CN to look for # Get available certificates split ws_general_query "AMT_PublicKeyCertificate" , wsbatchenum "wsman_answer" ws_general_query length wsman_ans_length wsman_answer.AMT_PublicKeyCertificate.responses set i 0 :loop_ans-%%%~%%% # Get the current subject name set curSubject wsman_answer.AMT_PublicKeyCertificate.responses.{i}.Subject IndexOf pos curSubject "CN=%%%CN%%%" jump :cnFound-%%%~%%% pos ">=" 0 add i i 1 jump :loop_ans-%%%~%%% i "<" wsman_ans_length jump :cnNotFound-%%%~%%% :cnFound-%%%~%%% # Set the reference to the certificate set certInstanceId wsman_answer.AMT_PublicKeyCertificate.responses.{i}.InstanceID set certHandle "%3CAddress%20xmlns=%22http://schemas.xmlsoap.org/ws/2004/08/addressing%22%3Ehttp://schemas.xmlsoap.org/ws/2004/08/addressing%3C/Address%3E%3CReferenceParameters%20xmlns=%22http://schemas.xmlsoap.org/ws/2004/08/addressing%22%3E%3CResourceURI%20xmlns=%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd%22%3Ehttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate%3C/ResourceURI%3E%3CSelectorSet%20xmlns=%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd%22%3E%3CSelector%20Name=%22InstanceID%22%3E{certInstanceId}%3C/Selector%3E%3C/SelectorSet%3E%3C/ReferenceParameters%3E" # Set method parameters jsonparse wsargs "%7B%22AccessInfo%22:%22%%%FQDN%%%%22,%22InfoFormat%22:%22201%22,%22Port%22:%%%Port%%%,%22AuthMethod%22:%221%22%7D" set wsargs.Certificate certHandle # Execute call to AddMpServer wsexec "AMT_RemoteAccessService" "AddMpServer" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Management Prescence Server (MPS) successfully added to the Intel(R) AMT Subsystem" set PullRemoteAccess 1 jump :end-%%%~%%% :cnNotFound-%%%~%%% print "Couldn't find a certificate matching the value of CN=%%%CN%%%" :error-%%%~%%% print "Call failed with error {wsman_result}" :end-%%%~%%% set AMT_RemoteAccessService set certHandle set curSubject set i set pos set ws_general_query set wsargs set wsman_answer set wsman_result set wsman_result_str set certInstanceId set wsman_ans_length ``` -------------------------------- ### Add Certificate to Intel AMT Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Uploads a chain or trusted root certificate to the Intel AMT certificate store. ```MeshCommander Script jsonparse wsargs "%7B%7D" set wsargs.CertificateBlob "%%%CertBin%%%" jump :certroot %%%CertType%%% "=" 1 print "Adding certificate..." wsexec "AMT_PublicKeyManagementService" "AddCertificate" wsargs jump :certdone :certroot print "Adding root certificate..." wsexec "AMT_PublicKeyManagementService" "AddTrustedRootCertificate" wsargs :certdone set wsargs set AMT_PublicKeyManagementService set PullCertificates 1 ``` -------------------------------- ### Add MPS Server via Certificate Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures a new CIRA server (MPS) by searching for a specific certificate and executing the AddMpServer method. ```MeshCommander Script # Get the input from user for the CN to look for # Get available certificates split ws_general_query "AMT_PublicKeyCertificate" , wsbatchenum "wsman_answer" ws_general_query length wsman_ans_length wsman_answer.AMT_PublicKeyCertificate.responses set i 0 :loop_ans-%%%~%%% # Get the current subject name set curSubject wsman_answer.AMT_PublicKeyCertificate.responses.{i}.Subject IndexOf pos curSubject "CN=%%%CN%%%" jump :cnFound-%%%~%%% pos ">=" 0 add i i 1 jump :loop_ans-%%%~%%% i "<" wsman_ans_length jump :cnNotFound-%%%~%%% :cnFound-%%%~%%% # Set the reference to the certificate set certInstanceId wsman_answer.AMT_PublicKeyCertificate.responses.{i}.InstanceID set certHandle "%3CAddress%20xmlns=%22http://schemas.xmlsoap.org/ws/2004/08/addressing%22%3Ehttp://schemas.xmlsoap.org/ws/2004/08/addressing%3C/Address%3E%3CReferenceParameters%20xmlns=%22http://schemas.xmlsoap.org/ws/2004/08/addressing%22%3E%3CResourceURI%20xmlns=%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd%22%3Ehttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate%3C/ResourceURI%3E%3CSelectorSet%20xmlns=%22http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd%22%3E%3CSelector%20Name=%22InstanceID%22%3E{certInstanceId}%3C/Selector%3E%3C/SelectorSet%3E%3C/ReferenceParameters%3E" # Set method parameters jsonparse wsargs "%7B%22AccessInfo%22:%22%%%IP%%%%22,%22InfoFormat%22:%223%22,%22Port%22:%%%Port%%%,%22AuthMethod%22:%221%22%7D" set wsargs.Certificate certHandle set wsargs.CN "%%%ServerName%%%" # Execute call to AddMpServer wsexec "AMT_RemoteAccessService" "AddMpServer" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Management Prescence Server (MPS) successfully added to the Intel(R) AMT Subsystem" set PullRemoteAccess 1 jump :end-%%%~%%% :cnNotFound-%%%~%%% print "Couldn't find a certificate matching the value of CN=%%%CN%%%" :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set AMT_RemoteAccessService set certHandle set curSubject set i set pos set ws_general_query set wsargs set wsman_answer set wsman_result set wsman_result_str set certInstanceId set wsman_ans_length ``` -------------------------------- ### End Script Block Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Handles final system status pulls and script completion notification. ```MeshCommander Script :end jump :SkipPullSystemStatus PullSystemStatus "!=" 1 PullSystemStatus :SkipPullSystemStatus jump :SkipPullEventLog PullEventLog "!=" 1 PullEventLog :SkipPullEventLog jump :SkipPullAuditLog PullAuditLog "!=" 1 PullAuditLog :SkipPullAuditLog jump :SkipPullCertificates PullCertificates "!=" 1 PullCertificates :SkipPullCertificates jump :SkipPullWatchdog PullWatchdog "!=" 1 PullWatchdog :SkipPullWatchdog jump :SkipPullSystemDefense PullSystemDefense "!=" 1 PullSystemDefense :SkipPullSystemDefense jump :SkipPullHardware PullHardware "!=" 1 PullHardware :SkipPullHardware jump :SkipPullUserInfo PullUserInfo "!=" 1 PullUserInfo :SkipPullUserInfo jump :SkipPullRemoteAccess PullRemoteAccess "!=" 1 PullRemoteAccess :SkipPullRemoteAccess jump :SkipPullEventSubscriptions PullEventSubscriptions "!=" 1 pulleventsubscriptions :SkipPullEventSubscriptions print "Script Completed" ``` -------------------------------- ### Add Event Subscription Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Registers a new event subscription with specified filter and URL parameters. ```MeshCommander Script print "Adding subscription: %%%SubscriptionUrl%%%" split filters "Intel(r) AMT:ME Presence,Intel(r) AMT:User,Intel(r) AMT:All,Intel(r) AMT:Platform,Intel(r) AMT:CorePlatform,Intel(r) AMT:Features,Intel(r) AMT:FW ProgressEvents" "," set filter filters.%%%SubscriptionFilter%%% jsonparse subfilter "%7B%22InstanceID%22:%22{filter}%22%7D" wssubscribe "CIM_FilterCollection" "%%%SubscriptionType%%%" "%%%SubscriptionUrl%%%" subfilter "%%%SubscriptionArgs%%%" # End of script jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set filters set filter set subfilter set PullEventSubscriptions 1 ``` -------------------------------- ### Set Script Speed Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures the execution delay between script steps in milliseconds. ```text scriptspeed %%%delay%%% ``` -------------------------------- ### Manage Intel AMT User Accounts Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Scripts for enumerating, searching, and deleting user accounts from Intel AMT. ```MeshCommander Script GetSidByteArray ToggleAccount "%%%sid%%%" btoa ToggleAccount ToggleAccount # Fetch all of the account handles print "Fetching account handles..." jsonparse wsargs "%7B %22StartIndex%22:1 %7D" wsexec "AMT_AuthorizationService" "EnumerateUserAclEntries" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 set AccountHandles AMT_AuthorizationService.Body.Handles set wsargs set AMT_AuthorizationService set wsman_result set wsman_result_str length AccountHandlesCount AccountHandles # Get all of the account information print "Fetching all account information..." set i 0 :fetchAccountLoop-%%%~%%% set fetchHandle AccountHandles.{i} jsonparse wsargs "%7B %22Handle%22:{fetchHandle} %7D" wsexec "AMT_AuthorizationService" "GetAclEnabledState" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 set AccountEnabled{i} AMT_AuthorizationService.Body.Enabled wsexec "AMT_AuthorizationService" "GetUserAclEntryEx" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 set AccountName{i} AMT_AuthorizationService.Body.KerberosUserSid set AccountAccess{i} AMT_AuthorizationService.Body.AccessPermission set AccountRealms{i} AMT_AuthorizationService.Body.Realms add i i 1 jump :fetchAccountLoop-%%%~%%% i "<" AccountHandlesCount set AMT_AuthorizationService set fetchHandle set wsargs # Search for a matching account print "Searching accounts..." set i 0 :searchAccountLoop-%%%~%%% set searchHandle AccountHandles.{i} jump :foundAccount AccountName{i} "=" ToggleAccount add i i 1 jump :searchAccountLoop-%%%~%%% i "<" AccountHandlesCount jump :end-%%%~%%% # Account found, delete it :foundAccount print "Account %%%sid%%% found at index {i}, deleting it..." set deleteHandle AccountHandles.{i} jsonparse wsargs "%7B %22Handle%22:{deleteHandle} %7D" wsexec "AMT_AuthorizationService" "RemoveUserAclEntry" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Done, account %%%sid%%% deleted." set PullUserInfo 1 jump :end-%%%~%%% # End of script jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` ```MeshCommander Script # Fetch all of the account handles print "Fetching account handles..." jsonparse wsargs "%7B %22StartIndex%22:1 %7D" wsexec "AMT_AuthorizationService" "EnumerateUserAclEntries" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 set AccountHandles AMT_AuthorizationService.Body.Handles set wsargs set AMT_AuthorizationService set wsman_result set wsman_result_str length AccountHandlesCount AccountHandles # Get all of the account information print "Fetching all account information..." set i 0 :fetchAccountLoop-%%%~%%% set fetchHandle AccountHandles.{i} jsonparse wsargs "%7B %22Handle%22:{fetchHandle} %7D" wsexec "AMT_AuthorizationService" "GetAclEnabledState" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 set AccountEnabled{i} AMT_AuthorizationService.Body.Enabled wsexec "AMT_AuthorizationService" "GetUserAclEntryEx" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "AMT-ACCOUNT: {AMT_AuthorizationService.Body.DigestUsername}, {AMT_AuthorizationService.Body.AccessPermission}, [{AMT_AuthorizationService.Body.Realms}]" add i i 1 jump :fetchAccountLoop-%%%~%%% i "<" AccountHandlesCount set AMT_AuthorizationService set fetchHandle set wsargs # End of script jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Add MPS Server via Username/Password Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures a new CIRA server (MPS) using an IP address and username/password authentication. ```MeshCommander Script # Set method parameters jsonparse wsargs "%7B%22AccessInfo%22:%22%%%IP%%%%22,%22InfoFormat%22:%223%22,%22Port%22:%%%Port%%%,%22AuthMethod%22:%222%22,%22Username%22:%22%%%username%%%%22,%22Password%22:%22%%%password%%%%22%7D" set wsargs.CN "%%%ServerName%%%" # Execute call to AddMpServer wsexec "AMT_RemoteAccessService" "AddMpServer" wsargs "" jump :error-%%%~%%% wsman_result "!=" 200 print "Management Prescence Server (MPS) successfully added to the Intel(R) AMT Subsystem" set PullRemoteAccess 1 jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% set AMT_RemoteAccessService set wsargs set wsman_answer set wsman_result set wsman_result_str set wsman_ans_length ``` -------------------------------- ### Set Ping Response Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures Intel AMT response settings for ICMP and RMCP ping requests. ```scriptblock split ws_general_query "*AMT_GeneralSettings" , wsbatchenum "wsman_answer" ws_general_query jump :error-2 wsman_result "!=" 200 set wsman_answer.AMT_GeneralSettings.response.PingResponseEnabled "%%%icmpPingResponse%%%" set wsman_answer.AMT_GeneralSettings.response.RmcpPingResponseEnabled "%%%rmcpPingResponse%%%" wsput "AMT_GeneralSettings" wsman_answer.AMT_GeneralSettings.response jump :error-2 wsman_result "!=" 200 set PullSystemStatus "1" jump :end-2 :error-2 print "Call failed: {wsman_result_str}" :end-2 ``` -------------------------------- ### Set Variable Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Assigns a value to a specified variable name. ```text set %%%var%%% %%%value%%% ``` -------------------------------- ### Set Active Features Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Configures Intel AMT active features such as redirection ports and SOL/IDER states. ```MeshCommander Script split ws_optIn_query "*AMT_RedirectionService" , wsbatchenum "wsman_answer" ws_optIn_query jump :error-%%%~%%% wsman_result "!=" 200 set wsman_answer.AMT_RedirectionService.response.ListenerEnabled "%%%listenerEnabled%%%" set wsman_answer.AMT_RedirectionService.response.EnabledState "%%%enabledState%%%" jsonparse wsargs "%7B %22RequestedState%22:%22%%%enabledState%%%%22 %7D" wsexec "AMT_RedirectionService" "RequestStateChange" wsargs wsput "AMT_RedirectionService" wsman_answer.AMT_RedirectionService.response jump :error-%%%~%%% wsman_result "!=" 200 set PullSystemStatus "1" jump :end-%%%~%%% :error-%%%~%%% print "Call failed: {wsman_result_str}" :end-%%%~%%% ``` -------------------------------- ### Define Trusted CSME Root Hashes Source: https://github.com/ylianst/meshcommander/blob/master/trustedCA/hashes.txt An array of SHA-256 hashes representing trusted Intel OnDie CA root and intermediate certificates. ```javascript var trustedCsmeRoots = [ '3BA13766B1889DCB1E2D55BACCC9EC087452F78783E2EBAFD918FF4ED6ACC840', // www.intel.com / OnDie CA DEBUG Root Cert Signing CA 'C001DF02B31A60A2B37130365956400A2AFCFD147E8552FD7EA3F17F2AB0D457', // www.intel.com / ODCA CA2 CSME Intermediate CA '5E3EEE5748AC13E0B3D1227FCDC4751AA1402DDE8031D21F63CB4ECF43F02440' // www.intel.com / OnDie CA CSME Intermediate CA ]; ``` -------------------------------- ### Detect Wireless Intel AMT NIC Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Checks for the presence of a wireless Intel AMT Ethernet port and stores the result in the WiFiAmtNic variable. ```MeshCommander Script split ws_general_query "CIM_EthernetPort" wsbatchenum "wsman_answer" ws_general_query set i -1 jump :error-%%%~%%% wsman_result "!=" 200 getitem i wsman_answer.CIM_EthernetPort.responses "DeviceID" "Intel(r) AMT Ethernet Port 1" jump :amtCoreError-%%%~%%% i "<" 0 set WiFiAmtNic "true" print "WiFi AMT NIC found: true" jump :end-%%%~%%% :amtCoreError-%%%~%%% print "Wifi AMT NIC found: false" jump :end-%%%~%%% :error-%%%~%%% print "WSMAN call failed: {wsman_result_str}" :end-%%%~%%% set i set ws_general_query set wsman_answer set wsman_result ``` -------------------------------- ### Conditional Jump Source: https://github.com/ylianst/meshcommander/blob/master/scriptblocks.txt Redirects script execution to a label if the comparison between two arguments evaluates to true. ```text jump :%%%label%%% %%%arg1%%% "%%%comparator%%%" %%%arg2%%% ```