Zelix75
Zelix75

Reputation: 81

How to convert a Python file to a PowerShell file?

So, I made a Python file (.py) and I want to convert it into a PowerShell file (.ps1)
I tried this tool: https://github.com/x-j/ps1scriptify but every time I give it a .py file, it says:
Python script provided is not callable (does not contain a main block)
So I changed this: print("Hello, World") to this:
def main():
print("Hello, world")
main()
It still gives me the same error mentioned above.
Any help please?

Upvotes: 0

Views: 1597

Answers (1)

lxop
lxop

Reputation: 8605

That conversion script is expecting to see a block like

if __name__ == '__main__':
    main()

so pop that into your script instead of just the raw call to main().

Upvotes: 1

Related Questions