Follow

Oh my. can run a script file. But if you do that, you no longer can redirect stdout and stderr. Why? Because the file parameter needs to receive the last argument in the command... and stdout redirects also need to be the last argument in the command... so those get ignored.

Solution: invoke powershell twice:

powershell -command "powershell -file myscript.ps1" 1>>stdout.log 2>>stderr.log

And thanks, Microsoft.

· · Web · 3 · 2 · 3

I have published a script that lets us attach files to an email, send the email, and archive the files:
gist.github.com/aeveltstra/52f

@HPBlackMamba I hear you. In this case it isn't Microsoft who force me, but my employer. Which is no better!

@aeveltstra Hilarious. And I've heard rumors that Powershell would actually be liked by admins, but I would not know one who wouldn't call this an abomination.

@schaueho For a small language that gives access to the entirety of the DotNet Framework, which operates the entire system, it's quite... powerfull... ;)

Yes, there's nicer languages available. But do I need to install ghc or python if all I need is a send-mail? Or move files around?

@aeveltstra To be fair, I was thinking of Unix admins liking PowerShell, so the natural competition would be bash. But this would not give you the same deep .net integration.

@schaueho Agreed! Using powershell on Unix or Linux or something alike would feel out of place.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!