database – i want to execute a .ps1 powershell script in red hat linux server

database – i want to execute a .ps1 powershell script in red hat linux server

Four years later from original question microsoft releases powershell for linux. And its opensource: https://github.com/PowerShell/PowerShell

In linux environment you can use syntax like this: (script.ps1, executable)

#!/usr/bin/powershell -Command

write-host -fore Green executing PowerShell!;

Pash is a cross-platform mono clone of Powershell which is under active development.
You only need to download, build it with xbuild, and run it.
Just like with Powershell on Windows you can execute your script with

& /path/to/script.ps1

database – i want to execute a .ps1 powershell script in red hat linux server

After installing powershell, easy enough:

thufir@dur:~/powershell$ 
thufir@dur:~/powershell$ ./hello_world.ps1
hello world
done
thufir@dur:~/powershell$ 
thufir@dur:~/powershell$ cat hello_world.ps1 
#!/usr/bin/pwsh -Command


echo hello world
done


thufir@dur:~/powershell$ 

Not sure why its pwsh and not powershell, but thats Linux for you.

Leave a Reply

Your email address will not be published. Required fields are marked *