Output
PS> $uf1 = '%Y%m%dT%H%M%S'
PS> $tsc = {Get-Date -uFormat "$uf1"}
PS> $tsq = 'Get-Date -uFormat "$uf1"'
PS>
PS> Get-Variable ts?
Name Value
---- -----
tsc Get-Date -uFormat "$uf1"
tsq Get-Date -uFormat "$uf1"
PS> & $tsc
20170707T015431
PS> & $tsq
& : The term 'Get-Date -uFormat "$uf1"' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & $tsq
+ ~~~~
+ CategoryInfo : ObjectNotFound: (Get-Date -uFormat "$uf1":String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS>
PS> Invoke-Expression $tsc
Invoke-Expression : Cannot evaluate parameter 'Command' because its argument is specified as a script block and there is no input. A script block cannot be evaluated without input.
At line:1 char:19
+ Invoke-Expression $tsc
+ ~~~~
+ CategoryInfo : MetadataError: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : ScriptBlockArgumentNoInput,Microsoft.PowerShell.Commands.InvokeExpressionCommand
PS> Invoke-Expression $tsq
20170707T015636
PS>
考察
Quotes 括りの文字列の場合は、コマンドとして認識しないが、braces{} Script Block であれば、コマンドを認識している。