How to use Put File and $scriptPath variable when using Powershell to extend Pattern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 10:34 AM
Hi Folks, I'm taking my first steps into customizing Discovery Patterns and want to use a simple Power Shell command to retrieve the Audio Driver Version in use on any discovered workstation as an extension of the 'Windows - Desktop Pattern'.
I have found that using Put File is the best approach to avoid the PS syntax issues in the Pattern Designer. So I have created the PS file and used 'uploaded files' to publish it to the mid server, created the first step to use the operation 'Put File' and selected the variable name $ScriptPath.
For the second step I use 'Parse Command Output' and added "powershell.exe -ExecutionPolicy Bypass" + $scriptPath
However I get no results in the Output Window. I have tested the script on my own machine using PS and it works. I'm also using my own machine as the debugging target without success.
Any help or references to supporting materials would be appreciated, thanks Richard.
The script I'm calling is just...
Get-WmiObject Win32_PnPSignedDriver | select DeviceName, Manufacturer, DriverVersion | where {$_.DeviceName -like "High Definition Audio Device*" -or $_.DeviceName -eq "Realtek Audio" }
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2022 03:34 PM
I would start the troubleshooting by looking at the MID Server logs, you may need to set the MID Server parameter mid.log.level to debug so you can see more information and if there is any response back from the PowerShell command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 02:08 AM
Thank you, that helped and allowed me to find the problem. Which was a schoolboy error on my part I'll admit.
To close this out the issue was a missing space in the following which I have now corrected and highlighted in case anyone else finds this helpful...
If you don't add a space in the command details as below it will be interpreted as...
'powershell.exe -ExecutionPolicy Bypassc:\\temp\\
Can I mark my own answer as correct or would that be conceited of me !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 07:11 AM
Hi, How to use $script path variable? Do we need to set and assign path to this parameter first and use it in put file operation? I am also facing the same issue but in my case i need to run .vbs script file . i have no clue why $scriptpath is not working for me. Thanks .