Mask .Net Activity Output Value in the logs

DevEngineReq 16 Reputation points
2025-03-10T12:00:57.4466667+00:00

Is there a possibility to mask the .Net Activity Output Value in the logs without deactivate "storing published data" to pass through sensible data.

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
252 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. XinGuo-MSFT 21,751 Reputation points
    2025-03-11T06:55:09.96+00:00

    Hi,

    As far as I know, .Net Activity does not have this feature built-in.

    To mask the PowerShell output value in logs without deactivating "storing published data," you can use several techniques to ensure sensitive data is not exposed.

    Here are some approaches:

    1. Using SecureString

    Convert sensitive data to a SecureString to prevent it from being logged in plain text.

    # Convert plain text password to SecureString
    $password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force
    
    # Use the SecureString in your command
    $credential = New-Object System.Management.Automation.PSCredential ("username", $password)
    
    1. Masking Output with Regex

    You can use regex to mask sensitive data before logging it.

    # Function to mask sensitive data
    function Mask-SensitiveData {
        param (
            [string]$input
        )
        # Example: Mask email addresses
        $input -replace '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}', '*****'
    }
    
    # Example usage
    $output = "User email: user@example.com"
    $maskedOutput = Mask-SensitiveData -input $output
    Write-Output $maskedOutput
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.