0

I am using below code in shell. I need to run the same in PowerShell.
I have frame list in file and I need to excute the command in loop and I need append the prefix variable to each output

for g in `cat /home/capacity-report/vmax3-frame.txt`
do
    echo $g; `symsg -sid $g list -v` > /home/capacity-report/sg
done
2
  • Could you provide an example for Input and Output file to see what is going on. Commented Mar 29, 2019 at 11:46
  • What environment is this intended for? Windows/Linux/MacOs? Maybe the tag powershell-core is more appropriate? Commented Mar 29, 2019 at 11:53

1 Answer 1

2

The PowerShell code for that shell snippet is pretty similar to the original:

foreach ($g in cat 'C:\path\to\input.txt') {
    echo $g; Invoke-Expression "$(symsg -sid $g list -v)" > 'C:\path\to\output.txt'
}

And the next time please try doing this yourself first. SO is not a free translation service. I'm just making an exception today because the wheather is so nice.

Sign up to request clarification or add additional context in comments.

8 Comments

sorry not working getting error..I am not able to attach screenshot image. i think the Invoke-Expression command not excuting
I am using power-shell to execute in loop and get the details and append prefix to each line
i need to execute this command echo $g; Invoke-Expression "$(Get-vm -name $g*|get-datastore|select-object *|grep DatastoreBrowserPath)" >> "c:\test"
@BelvendranRanjan "get the details and append prefix to each line" That is not what your bash code is doing. Please edit your question and show samples of desired and actual output, and also the error you're getting.
PLEASE. EDIT. YOUR. QUESTION.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.