bash to powershell

Home Forums Scripting PowerShell bash to powershell

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    vickynet
    Member
    #620166

    Hi all,

    I have bash script that i need to want to convert into powershell or write into powershell script can u someone help on below script , because am new to powershell so kindly help me.

    #!/bin/bash

    DESC=$1
    HOSTNAME=$2
    DATE=$3
    REPLACE=”-”
    DATE=${DATE//”.”/$REPLACE}
    TIME=$4
    SEV=$5
    SEV=${SEV^^}
    IP=$6
    TIME=date -d "$DATE $TIME" +%s

    NOTES=”SEV : $SEV\tDESC: $DESC\tHOSTNAME: $HOSTNAME\tDATE: $DATE $TIME”
    COMP=””

    echo “Started at $TIME with $NOTES” >> /tmp/push.log
    if [[ $DESC =~ .*load.* || $DESC =~ .*CPU.* ]]
    then
    COMP=”Load”
    fi

    if [[ $DESC =~ .*Service.* || $DESC =~ .*running.* ]]
    then
    COMP=”Service”
    fi

    if [[ $DESC =~ .*PROCS.* || $DESC =~ .*processes.* ]]
    then
    COMP=”Process”
    fi

    if [[ $DESC =~ .*SWAP.* || $DESC =~ .*Swap.* ]]
    then
    COMP=”Swap”
    fi

    if [[ $DESC =~ .*DISK.* || $DESC =~ .*inode.* || $DESC =~ .*folder.* ]]
    then
    COMP=”Disk”
    fi

    if [[ $DESC =~ .*Memory.* || $DESC =~ .*MEMORY.* ]]
    then
    COMP=”Memory”
    fi

    if [[ $DESC =~ .*Logins.* || $DESC =~ .*Login.* ]]
    then
    COMP=”Security”
    fi

    if [[ $DESC =~ .*docker.* || $DESC =~ .*Container.* ]]
    then
    COMP=”Docker”
    fi

    if [[ $DESC =~ .*bandwidth.* || $DESC =~ .*RX.* ]]
    then
    COMP=”Interface”
    fi

    curl -i -X POST ‘http://x.x.x.x:8000/evm/api1.0/endpoints/eventreceiver’ -d “{\”ci_name\”: \”$HOSTNAME\”, \”component\”: \”$COMP\”, \”description\”: \”$DESC\”, \”notes\”: \”$NOTES\”, \”severity\”: \”$SEV\”, \”event_created_time\”: \”$TIME\”, \”source\”: \”ZABBIX\”}” -H “Content-Type: Application/json” >> /tmp/curl.log 2>> /tmp/curl.log

    echo “Finished with $?” >> /tmp/push.log

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.