need to convert Shellscript to powershell

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
moshelakin
Posts: 1
Last visit: Tue Dec 28, 2021 8:53 pm

need to convert Shellscript to powershell

Post by moshelakin »

I have a shellscript and need to convert to powershell..can someone help me on this?

here is the script
-------------------

echo "[{" > data.txt
for i in `cat pending.txt`
do
timeout 2 telnet $i 22 > test.txt 2>&1
cat test.txt |grep "Connected to" >/dev/null 2>&1
if [[ $? == 0 ]]; then
echo $i >> completed.txt
echo " \"status\" : \"Completed\", " >> data.txt
echo " \"comments\" : \"Server is reachable at $(date +"%m/%d/%Y %T") EST\", " >> data.txt
echo " \"assignee\" : \"WebServices\", " >> data.txt
echo " \"serverName\" : \"$i\" " >> data.txt
echo "}, { " >> data.txt
fi
done
head -n -1 data.txt > data.txt.tmp
mv data.txt.tmp data.txt
echo "}" >> data.txt
echo "]" >> data.txt
diff -a --suppress-common-lines -y pending.txt completed.txt | awk {'print $1'} |grep -v ">" > test1.txt
mv test1.txt pending.txt
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: need to convert Shellscript to powershell

Post by jvierra »

This topic is 2 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked