Pasting images into org-mode on WSL

There are 101 different solutions to the problem of pasting images into org-mode
on the Windows Subsystem for Linux (WSL). My solution is a hybrid of a few of
them I found on stack-exchange and the like, after playing with them for a while
and needing to fix some bugs. The most notable bug which was the handling of
spaces in filenames and translating WSL paths to Windows paths.

Copy and paste images into org-mode on WSL/Windows.

(defun as-windows-path (unix-path)
    (concat "wslpath -w '" unix-path "'")) 0 -1))

(defun powershell (script)
  (call-process "powershell.exe" nil nil nil
                "-Command" (concat "& {" script "}")))

(defun my-org-screenshot ()
  "Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file."
  (let* ((filename
            (concat (buffer-file-name)
                    (format-time-string "%Y%m%d_%H%M%S_")) ) ".png"))
          (concat (as-windows-path(file-name-directory filename))
                  (file-name-nondirectory filename)))
          (concat "(Get-Clipboard -Format image).Save('" wsl-path "')")))

    (shell-command "SnippingTool.exe /clip")
    (powershell ps-script)

    (insert "#+ATTR_ORG: :width 500")
    (insert (concat "[[file:" filename "]]"))

(global-set-key "\C-cs" 'my-org-screenshot)