Embedded PowerShell Scripts

Forums Desktop Info Embedded PowerShell Scripts

Viewing 6 reply threads
  • Author
    Posts
    • #5427
      Nathan_KNathan_K
      Participant

      Hey Glenn,

      I’m trying to use the SET-CONTENT feature to pull a script inside of the INI, but I can’t seem to pass an argument to the embedded script like I can with an external call. Any thoughts?

      Thanks!

    • #5428
      GlennGlenn
      Keymaster

      you can’t just add it to the parameters option?

    • #5431
      Nathan_KNathan_K
      Participant

      Here is my code block from the config. You can see the result in the attached screenshot.

      CMD=interval:10,text:Local Fixed Disks,read-as-csv:1,csv-header:1,file:powershell.exe,parameters:.\scripts\BitLocker-Status.ps1 -query "Local Fixed",trim:1,show-window:0,color:ffbb77,chart:bar2 scale:linear max:100 series1:{{((%Size%-%FreeSpace%)/%Size%)*100}} threshold:90 0000FF,hide-no-result:1,display:%Name% {{%Size%-%FreeSpace%}}[1.0b]B / {{%Size%}}[1.0b]B ({{((%Size%-%FreeSpace%)/%Size%)*100}}[1.0d]% used) %chart%| BitLocker Status: %BitLocker%

      That calls the external PS1. If I use the same line and replace the PS1 with my SET-SECTION variable, I get no output data. If I hard code “Local Fixed” into the PS block, I get all bad data.

    • #5433
      Nathan_KNathan_K
      Participant

      Here is my “SET-SECTION” block.

      and

    • #5435
      GlennGlenn
      Keymaster

      This has taken me all day to figure out!! I must be getting old 😐

      I’m adding one extra user variable before the CMD which contains the query type LOCAL FIXED or REMOVABLE. This is referenced inside the actual embedded script.

      That user variable is added to the embedded script:

      the rest of the script requires you to get the quote characters correct. For the most part, the single quote character seems to work. Hopefully the following code displays correctly on the forum:

      • This reply was modified 2 months ago by GlennGlenn.
      • This reply was modified 2 months ago by GlennGlenn.
      • This reply was modified 2 months ago by GlennGlenn.
    • #5438
      GlennGlenn
      Keymaster

      this shows the standard disk display on the top and your display underneath.

      Attachments:
    • #5441
      Nathan_KNathan_K
      Participant

      I think most of my issues were the single vs double quotes. I did figure out how to set the query inline as well.

      parameters:-Command "& {$query='Local Fixed'; %bitlocker-status%}"

      That seems to work correctly.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.
Glenn's Page