Jump to content

Having Script Problems, results wont save back to Custom Variable

Mike Leger

Recommended Posts

So in the script i have Output as FileShares as a text output

In Automation > Custom Fields I have another one called FileShares as a custom Text field as well.

My script is pretty basic, so I don't see why its not saving the field.

# Outputs
$FileShares = "0"
# Get all shared folders on the local computer
$shares = Get-WmiObject -Class Win32_Share | Select-Object Name, Path

# Output the list of shares
if ($shares) {
    Write-Host "Current File Shares on $env:COMPUTERNAME:`n"
    $shares | Format-Table -AutoSize
} else {
    Write-Host "No file shares found on $env:COMPUTERNAME."
Start-Process -FilePath "$env:PWY_HOME\CLI.exe" -ArgumentList ("setVariable FileShares ""$shares""") -Wait

So all I'm doing is getting a list of shared folders on a computer, saving it as $shares, and then writing that as a formatted table.

At the end, i'm running the CLI, to set the variable of FileShares to the results of $shares

The script runs, and i can see results, however I cannot see the results in the computers custom field.

Link to comment
Share on other sites

  • Administrators

Hey @Mike Leger

Thanks for reaching out! From what I can tell The output is formatted as Table. But type is TEXT. Only free text can be output and Table format is not supported.

Let me know if this makes any sense and if you have any other questions please feel free to reach out any time.


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...