---
title: "How to Up Your PowerShell Game with 1E Tachyon"
description: "Learn how to build a PowerShell script to check for webserver response time and clear remote PC DNS caches using 1E’s Tachyon."
canonical: "https://adamtheautomator.com/1e-powershell-2/"
---

# How to Up Your PowerShell Game with 1E Tachyon

> Learn how to build a PowerShell script to check for webserver response time and clear remote PC DNS caches using 1E’s Tachyon.

Source: https://adamtheautomator.com/1e-powershell-2/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![How to Up Your PowerShell Game with 1E Tachyon](https://adamtheautomator.com/wp-content/uploads/2022/02/How-to-Up-Your-PowerShell-Game-with-1E-Tachyon.jpg)

# How to Up Your PowerShell Game with 1E Tachyon

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)22 February 20223 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[1E](/tag/1e/)[1E Tachyon](/tag/1e-tachyon/)[Sponsored](/tag/sponsored/)

Table of Contents

*   [Fixing Endpoint Issues with PowerShell Remoting](#fixing-endpoint-issues-with-powershell-remoting)
*   [Saving Time and Increasing Efficiency with 1E Tachyon and PowerShell](#saving-time-and-increasing-efficiency-with-1e-tachyon-and-powershell)
*   [The PowerShell Script](#the-powershell-script)
*   [Running the PowerShell Dynamic Instruction](#running-the-powershell-dynamic-instruction)
*   [My Conclusion](#my-conclusion)

_“Hello IT, my website is not loading.”_ — Sound familiar? It sure does if you’ve worked with desktop or end-user support. And is most cases, flushing the DNS cache on the user’s computer can help. Granted that there are many possible reasons for this issue, but you have to start somewhere.

Why not automate the monitoring of URL response times and flush the DNS cache on remote machines. As a result, you can potentially reduce or prevent service desk calls. Yes, you can do so with the Tachyon and PowerShell.

This article will show you how you can use [1E’s Tachyon platform](https://www.1e.com/products/tachyon/) and its [`PSTachyonToolkit`](https://1eportal.force.com/s/article/TachyonPowerShellToolkit) module integration to solve this example use-case scenario.

## Fixing Endpoint Issues with PowerShell Remoting

Having used PowerShell for automation for most of my IT career, my instinct would be to create a script or function for this purpose. For example, the code below is for a reusable script named `PSFlushDNS.ps1`.

This script will perform a URL query on remote computers. If the total duration exceeds a specified threshold in milliseconds, the script will execute the `ipconfig /flushdns` command to flush the remote computer’s DNS cache.

```powershell
# PSFlushDNSCache.ps1
[CmdletBinding()]
param(
    # List of target computers
    [Parameter(Mandatory)]
    [string[]]
    $TargetComputer,

    # URL for testing (ie. yahoo.com, https://www.ietf.org/, http://powershell.org)
    [Parameter(Mandatory)]
    [string]
    $URL,

    # Duration threshold in milliseconds
    [Parameter(Mandatory)]
    [int]
    $Threshold
)

$TargetComputer | ForEach-Object {
    $_ | Out-Default
        Invoke-Command -ComputerName $_ -ScriptBlock {
        # Set the URL string
        $URL = $using:URL
        # Set the response time threshold in milliseconds
        $Threshold = $using:ResponseThresholdMS
        # If the URl does not begin with 'http', insert the 'http://' string prfix.
        if ($URL.Substring(0, 4) -notcontains 'http') {
            $URL = "http://$($URL)"
        }
        # Download the website content and return the duration in milliseconds.
        $wc = New-Object System.Net.WebClient
        $result = Measure-Command { $wc.DownloadString($URL) }

        # Display duration
        $result.Milliseconds | Out-Default

        # Check if the total duration is over the threshold.
        # If so, flush the DNS cache.
        if ($result.Milliseconds -gt $Threshold) {
            cmd /c 'ipconfig /flushdns'
        }
    }
}
```

Related:[Understanding and Building PowerShell Modules](https://adamtheautomator.com/powershell-modules/)

Running the script using the command below will target two computers namely `PC0003` and `PC0006`.

```powershell
.\PsFlushDnsCache.ps1 `
    -TargetComputer @('PC0003','PC0006') `
    -URL yahoo.com `
    -Threshold 400
```

The result below shows that the script successfully flushed the DNS cache for `PC0006`, which took `635` milliseconds to query `yahoo.com`.

But `PC0003` failed due to a WinRM-related error. The WinRM service is probably not running, not configured, or perhaps the remote computer is offline. Whatever the reason, the bottom line is this error will require more troubleshooting. What if you need to run the same script on hundreds of PC?

![Flush DNS via PowerShell remoting](https://adamtheautomator.com/wp-content/uploads/2022/02/image-276.png)

Flush DNS via PowerShell remoting

This script is basic and can be improved to include checking for device connectivity, adding error handling, and so on. But even then, the script will still be dependent on [PowerShell](https://adamtheautomator.com/psremoting/) remoting and WinRM.

Related:[PowerShell Remoting: The Ultimate Guide](https://adamtheautomator.com/psremoting/)

## Saving Time and Increasing Efficiency with 1E Tachyon and PowerShell

Doing away with PowerShell remoting, you could instead use PowerShell to integrate with Tachyon to run instructions. You can always take advantage of existing instructions or combine them with new custom instructions as you see fit.

But in this example, I’ll stick to running PowerShell scripts as dynamic instructions. This way, I do not have to publish the Tachyon instruction beforehand, and the PowerShell script will run as though I’m executing them locally on the remote machine.

### The PowerShell Script

The code below is a modified version of the previous script, removing the remoting logic. Also, this script accepts two parameters only — `URL` and `Threshold`. You’ll also notice that the final line returns the output in JSON format, which is important for proper serialization with Tachyon.

```powershell
# TachyonFlushDNSCache.ps1

[CmdletBinding()]
param(
    # URL for testing (ie. yahoo.com, https://www.ietf.org/, http://powershell.org)
    [Parameter(Mandatory)]
    [string]
    $URL,

    # Duration threshold in milliseconds
    [Parameter(Mandatory)]
    [int]
    $Threshold
)

# If the URl does not begin with 'http', insert the 'http://' string prfix to make a proper URL string.
if ($URL.Substring(0, 4) -notcontains 'http') {
    $URL = "http://$($URL)"
}

# Download the website content and measure the response duration
$wc = New-Object System.Net.WebClient
$duration = Measure-Command { $wc.DownloadString($URL) }

# Create a custom object to hold the result.
$output = '' | Select-Object ResponseTime, Result
$output.ResponseTime = $duration.TotalMilliseconds
$output.Result = "No action. Duration < ($($Threshold)ms)."

if ($duration.TotalMilliseconds -gt $Threshold) {
    $output.Result = [string](cmd /c 'ipconfig /flushdns')
}

# Return output in JSON format
$output | ConvertTo-Json
```

### Running the PowerShell Dynamic Instruction

With Tachyon, you already have an inventory of target devices, and you only need to filter based on your requirements. In this example, I’ll be targeting devices based on two locations; London and New York.

But first, I’ll import the `PSTachyonToolkit` module, connect to the Tachyon server, and set the instruction prefix that matches the Tachyon license.

```powershell
# Import the PSTahcyonToolkit module.
Import-Module 'C:\Program Files\1E\Tachyon\pstoolkit\PSTachyonToolkit.psd1'
# Connect to the Tachyon server.
Set-TachyonServer 1E01.corp.1EDemoLab.com
# Set the licensed dynamic instruction prefix.
Set-TachyonInstructionPrefix '1E-Demo'
```

Next, I’ll run the command below that targets the devices in the New York and London locations using the `Invoke-TachyonDynamic` cmdlet. To understand the command better, here are the parameters:

*   The `-Script` parameter specifies the PowerShell script to run on the remote computers.
    
*   The `-TargetScope` parameter accepts the filter expression. If a filter value contains spaces, make sure to enclose the value in square brackets. In this example, the filter is `location=[New York]`, which means that Tachyon will run the instruction against the devices in New York only.
    
*   The `-Parameters` parameter accepts the parameter(s) to pass to the script. The values must follow the same order in the script as an array. For example, the script accepts the `URL` and `Threshold` parameters, so the sample values are `@('yahoo.com',400)`.
    
*   The `-Schema` parameter is optional. I’m using this parameter to control the instruction output and filter which properties to return.
    
*   The `-Force` switch overrides the target machine’s script execution policy.
    

Related:[PowerShell Execution Policies: Understanding and Managing](https://adamtheautomator.com/set-executionpolicy/)

```powershell
# Run the script against the devices on location 1 (New York)
Invoke-TachyonDynamic `
-Script .\TachyonFlushDNSCache.ps1 `
-Parameters @('yahoo.com',400) `
-TargetScope "location=[New York]" `
-Schema 'ResponseTime double,Result string' `
-Force

# Run the script against the devices on location 2 (London)
Invoke-TachyonDynamic `
-Script .\TachyonFlushDNSCache.ps1 `
-Parameters @('yahoo.com',400) `
-TargetScope "location=London" `
-Schema 'ResponseTime double,Result string' `
-Force
```

![Running the PowerShell Script as a Dynamic Tachyon Instructions](https://adamtheautomator.com/wp-content/uploads/2022/02/image-277.png)

Running the PowerShell Script as a Dynamic Tachyon Instructions

Alternatively, I can combine the `TargetScope` filter expression to include both locations at once instead of running the instructions targeting different locations individually.

```powershell
# Run the script against the devices on New York and London endpoint devices
Invoke-TachyonDynamic `
-Script .\TachyonFlushDNSCache.ps1 `
-Parameters @('yahoo.com',400) `
-TargetScope "location=[New York] or location=London" `
-Schema 'ResponseTime double,Result string' `
-Force
```

![Running the PowerShell Script against endpoint devices on two locations at once](https://adamtheautomator.com/wp-content/uploads/2022/02/image-278.png)

Running the PowerShell Script against endpoint devices on two locations at once

There it is! Take this script, modify it to your needs, and perhaps learn more about how you can work with Tachyon in PowerShell.

## My Conclusion

With Tachyon and its PowerShell integration, you don’t need to become a Tachyon expert if you’re more comfortable with coding PowerShell. You can keep working with PowerShell and incorporate Tachyon’s features and power to make your work more efficient.

If you’re open to exploring Tachyon more, you may find that there could already be instructions that you can use for your specific use-cases. Take a look at the [Tachyon Exchange](https://tachyonexchange.1e.com/) and its 84 product packs, 799 instructions, and its 18 policies. Wouldn’t those be a time saver?

Related:[Related: Learning 1E’s Tachyon: Using Explorer](https://adamtheautomator.com/learn-with-me-tachyon-explorer/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2F1e-powershell-2%2F&text=How%20to%20Up%20Your%20PowerShell%20Game%20with%201E%20Tachyon)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2F1e-powershell-2%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2F1e-powershell-2%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/02/Autonomous-Persona-Management-using-1E-Tachyons-PowerShell-Toolkit.jpg)

### [Autonomous Persona Management using 1E Tachyon’s PowerShell Toolkit](/1e-powershell-3/)

Learn how to manage thousands of endpoints with dynamic tagging capabilities with 1E’s Tachon.

![](https://adamtheautomator.com/wp-content/uploads/2022/02/Getting-Started-with-1Es-Tachyon-and-PowerShell-1.jpg)

### [Getting Started with 1E’s Tachyon and PowerShell](/1e-powershell/)

Wrangle your endpoints with 1E’s Tachyon product and PowerShell in this in-depth tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2022/01/Exploring-Processes-and-Applications-with-1E-Tachyon.jpg)

### [Exploring Processes and Applications with 1E Tachyon](/1e-tachyon/)

Learn to use the PowerShell and Tachyon integration to solve a specific use-case scenario.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
