Ad Widget

Collapse

Send variable to powershell script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • funyfizik
    Junior Member
    • May 2021
    • 15

    #1

    Send variable to powershell script

    Hello, Im trying to send variable to PowerShell scrip ussing key:
    Code:
    usb.check["canon"]
    my script:

    Code:
    param ($param1)
    $result = get-pnpdevice | Select-String -Pattern $param1
    $res = $result | Select-String -Pattern $param1
    Write-Host $res
    But if i test it like:
    Code:
    usb.check["canon"]
    its not working.

    User parameter:

    Code:
    UserParameter=usb.check[*],for /F "tokens=* usebackq" %a in (`""powershell -NoProfile -ExecutionPolicy Bypass -File "C:\zabbix\usb-check.ps1" $1"`) do @echo %a
  • funyfizik
    Junior Member
    • May 2021
    • 15

    #2
    Sorry my mistake, its work:

    KEY
    Code:
    usb.check[sceye]
    UserParameter:
    Code:
    UserParameter=usb.check[*], powershell -NoProfile -ExecutionPolicy Bypass -File "C:\zabbix\usb-check.ps1" $1

    Comment

    Working...