Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

bash to powershell

Home Forums Scripting PowerShell bash to powershell

Viewing 1 post (of 1 total)
  • Author
    Posts

  • vickynet
    Participant
    #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.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: