---
sourceDocument: Brazil ServiceNow AI Platform Capabilities
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/servicenow-platform

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil ServiceNow AI Platform Capabilities

ft:clusterId :

    - platcap

bundleId :

    - platcap

workflow :

    - Platform


---

# MID Server PowerShell files

# MID Server PowerShell files {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of MID Server PowerShell files

ServiceNow MID Server uses PowerShell script and module files (.ps1 and .psm1) to execute automation tasks across various activity packs such as Active Directory, Exchange, and SCCM.
These scripts leverage credential testing, password encryption, and remote command execution to facilitate orchestration activities configured in the Orchestration Activity Designer or via MID Script Files.
Show full answer Show less  
The key script, **PSScript.ps1** , interacts with the **credential.psm1** module to verify access to remote hosts, relying on specific credential types to authenticate connections and run commands securely.

## Key Features

* **Credential Types and Testing:** The PowerShell activities support credential types like WMI, Exchange, Active Directory, and SCCM. If no credential type is specified, the default WMI test is used. The MID Server attempts credential validation against the target host before executing scripts, ensuring secure and appropriate access.
* **Exit Codes:** The `PSScript.ps1` script returns exit codes (0-4) indicating the outcome of script execution and credential testing, which are logged in the MID Server logs for troubleshooting and audit purposes.
* **Diagnostic Utilities:** The `DiagnosticsUtil.psm1` module provides logging functions such as `SNCLog-DebugInfo` and `SNCLog-ParameterInfo` to assist with debugging PowerShell orchestration activities, as well as `SNCObfuscate-Value` to obfuscate sensitive data in logs.
* **Credential Testing Functions:** The `Credentials.psm1` module contains functions to test user credentials against remote hosts using different methods (WMI, DirectoryEntry for AD, PowerShell remoting for Exchange and SCCM). It ensures that the MID Server uses the correct credentials to execute commands.
* **Credential Selection Behavior:** When targeting the MID Server itself, the service account is used directly, bypassing stored credentials. For other hosts, all stored Windows credentials are tested sequentially, and if all fail, the MID Server service account is used as a fallback.
* **Activity Pack Modules:** Separate module files (`ActiveDirectory.psm1`, `Exchange.psm1`, `SCCM.psm1`) contain functions specific to each activity pack's PowerShell scripts, encapsulating functionality for those platforms.

## Practical Implications for ServiceNow Customers

Understanding the MID Server PowerShell files and their credential handling is essential for securely automating remote operations through ServiceNow orchestration activities. Customers can expect:

* Reliable credential validation mechanisms before script execution ensuring secure access to target hosts.
* Clear exit codes and diagnostic logging to facilitate troubleshooting and script debugging.
* Modular scripts tailored for different systems (AD, Exchange, SCCM) simplifying integration and management.
* Automatic fallback to the MID Server service account when credential validation fails, reducing failure points.

By leveraging these PowerShell script modules and understanding their credential workflows, customers can effectively configure and troubleshoot orchestrated automation tasks within their ServiceNow environment.  
PowerShell functions are stored in script files (\*.ps1) that use a PowerShell Script
module (\*.psm1) file name extension.
The PowerShell functions are used by the PowerShell MID Server script files included in these activity packs:

* Active Directory
* Exchange
* SCCM
* PowerShell
{#mid-server-powershell-files__ul_gd5_554_cw}

## PSScript.ps1

This script performs a few tasks, such as credential testing, password encryption, and the
execution of scripts configured in the Orchestration Activity Designer or in MID Script
Files. However, this document focuses on how PSScript.ps1 uses the
credential.psm1 module for testing access to remote hosts.  
The PowerShell variables are generally used directly in the [PowerShell execution command](https://servicenow-prod.fluidtopics.net/EkQ33wueKVcFMzIg~zvMxg#t_MapPowershellVariablesToExecCmd "Use the input variables you created to configure the command that Orchestration executes on the Windows target machine.") or as arguments in the MID Server script file you specify. There are special variables that are passed to PSScript.ps1, such as credType. Figure 1. Using credType in execution parameters

## PowerShell credTypes

The PowerShell credential types:  
{#mid-server-powershell-files__table_pm5_b1p_cw__entry__2}

| Type | Description |
|-|-|
| WMI | testCredentialWMI |
| Exchange | testCredentilExchange |
| AD | testCredentilAD |
| SCCM | testCredentilSCCM |
[ ]

{#mid-server-powershell-files__table_pm5_b1p_cw}

If no credential type is passed to the PSScrip.ps1 script, the MID Server defaults to the
WMI test function to test access to the target host. If there is a credential type used, the
MID Server runs the corresponding test function for that credential type.

## Exit codes

These exit codes are returned from the PSScript.ps1 script and logged in the MID Server log
file.  
{#mid-server-powershell-files__table_r4l_n5q_dw__entry__2}

| Type | Test function |
|-|-|
| 0 | PowerShell command/script ran successfully. |
| 1 | Test finished successfully, but the command/script failed to execute. |
| 2 | Incorrect syntax passed to script. |
| 3 | All credentials including MID Server service account failed to execute the command/script. |
| 4 | Passed test and executed the activity, but an error was returned. Example user cannot be found. |
[Table 1. PSScript.ps1 exit codes]

{#mid-server-powershell-files__table_r4l_n5q_dw}

## DiagnosticsUtil.psm1 {#mid-server-powershell-files__section_rd2_vkl_4bb}

The MID Server uses this module file to perform PowerShell logging that assists debugging any Orchestration activity using PowerShell scripting. You can also add debugging statements directly to custom scripts.{#mid-server-powershell-files__table_sd2_vkl_4bb__entry__2}

| Utility | Description |
|-|-|
| SNCLog-DebugInfo | Log a debug message for a PowerShell script or PowerShell Orchestration activity. Examples: * `SNCLog-DebugInfo -message "My debug message..."` * `SNCLog-DebugInfo "My debug message"` {#mid-server-powershell-files__ul_qw4_knl_4bb} |
| SNCLog-ParameterInfo | Log a function parameter value. For `"function getHostName{ param( [String] $target )"`, the first value to the PowerShell hashtable is a string to indicate which function executes, and the values for each of the function parameters. Examples: * Function with single parameter: `SNCLog-ParameterInfo @("Running getHostName", $target)` Note: The debug message shows, '`Running getHostName $target:[actual value of $target]`'. * Function with multiple parameters: `SNCLog-ParameterInfo @("Running functionName", $param1, $param2, $param3)` {#mid-server-powershell-files__ul_azp_p4l_4bb} |
| SNCObfuscate-Value | Use this utility to encrypt values for security purposes. The function displays `"$variableName":***`, where \*\*\* is the obfuscated value. Example: `SNCObfuscate-Value $password` Note: The debug message reads: `"$password : ***"`. |
[Table 2. PowerShell diagnostic utilities]

{#mid-server-powershell-files__table_sd2_vkl_4bb}

## Credentials.psm1

The MID Server uses this module file to test access to a target host. The MID Server loops through all Windows credentials stored in its credentials table using the following access type functions, unless the PowerShell activity has a credential type (credType) defined. All ServiceNow® authored PowerShell activities are hard-coded to use a specific credential type. As a result, the MID Server only tests credential access against the designated function.{#mid-server-powershell-files__table_qmm_z1p_cw__entry__2}

| Function | Description |
|-|-|
| testCredentialWMI | Tests the given user and password on the target host using the Get-WMI object. |
| testCredentilAD | Tests the given user and password on the target host using the built-in DirectoryEntry object. |
| testCredentialExchange | Tests the given user and password to create a session on an Exchange host. This test uses the built-in PowerShell remoting feature on a remote host. WinRM is configured on Exchange servers by default. |
| testCredentialSCCM | Tests the given user and password to create a session on an SCCM server. This test uses the built-in PowerShell remoting feature on a remote host. This test requires WinRM to be configured. |
| testNoCredentialAccessWMI | Tests the given user and password on the target host, using the Get-WMI object. This test is used when no credType is used. |
[Table 3. PowerShell test functions]

{#mid-server-powershell-files__table_qmm_z1p_cw}  
Note:  
If the test passes using one of these functions, that credential is used to run the PowerShell script/command. If the tests fail to access the target host using these functions, the MID Server runs the PowerShell script/command under the account of the MID Server service.

This diagram illustrates the dependency of the credential selection behavior on the host
being targeted by the PowerShell activity. If the target host is the IP address or host name
of the MID Server, the MID Server bypasses all credentials in the Credentials table and uses
the account of the MID Server service. If the target host is not the MID Server, then all
Windows credentials are used first.
If all credentials in the Credentials table are unsuccessful in running the PowerShell
activity, then the MID Server uses the MID Server service account.  
Figure 2. PowerShell credential selection criteria

## ActiveDirectory.psm1

This module file stores the functions used by the PowerShell scripts shipped with the [Active Directory](https://servicenow-prod.fluidtopics.net/nOc5qDXOygzRoKMBS24KiA "The Active Directory (AD) activity pack enables an administrator to create, delete, and manage objects in Windows Active Directory, such as users, groups, and computers, using a ServiceNow Orchestration workflow.") activity pack.

## Exchange.psm1

This module file stores the functions used by the PowerShell scripts shipped with the [Exchange](https://servicenow-prod.fluidtopics.net/qPZZEm7F0sVKs8Hii3qZFg "The Exchange activity pack allows workflows to manage Microsoft Exchange mail systems.") activity pack.

## SCCM.psm1

This module file stores the functions used by the PowerShell scripts shipped with the [SCCM](https://servicenow-prod.fluidtopics.net/7vG5_OEzdqmfZoGTst9OPA "The Microsoft System Center Configuration Management (SCCM) activity pack provides Orchestration activities you can use to manage software deployments and collections on an SCCM server.") activity pack.

