Skip to content

Instantly share code, notes, and snippets.

@preavy
Created June 7, 2013 11:30
Show Gist options
  • Select an option

  • Save preavy/5728656 to your computer and use it in GitHub Desktop.

Select an option

Save preavy/5728656 to your computer and use it in GitHub Desktop.
Evaluate PowerShell code from inside Emacs
How to use:
Write some PowerShell code in any Emacs buffer.
Select the region to evaluate, then M-x eval-region-powershell to evaluate it as a PowerShell script block.
The output goes into *Shell Command Output*.
(defun eval-region-powershell ()
(interactive)
(shell-command
(concat "powershell -noprofile -encodedcommand "
(base64-encode-string
(encode-coding-string (buffer-substring (mark) (point)) 'utf-16le)))))
A great alternative to REPL-based development or the PowerShell ISE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment