Note that only the ascii 32 space is affected, 'all types of indentation' is really just the space ascii 32.
Variables don't need to be supporting anything because %variables can already store leading, consecutive, and trailing spaces.
As demonstrated by Ook with the file handling solution, only /returnex is needed to return a string containing leading/consecutive/trailing spaces.
There's a small issue in the code above though @Ook, /set by default will store any form of trailing/consecutive/leading spaces... except for a single trailing space, but it has since been fixed via the -p switch.