How can I execute multiple commands in PowerShell on one line?
I am trying to unlock the files in the directory and output their names:
@"powershell get-childitem E:\\WRT\\Downloads\\TouchGesturesVisio -Recurse ^|select BaseName,Extension ^|unblock-file"
I need to be able to do this in a stand-alone application, but so far I can only get one cmdlet to function.
When I run the command from the application, I get the following exception.
powershell get-childitem E:\WRT\Downloads\TouchGesturesVisio -Recurse ^|select B
aseName,Extension ^|unblock-file
Error unblock-file : The input object cannot be bound to any parameters for the
Error command either because the command does not take pipeline input or the inp
ut
Error and its properties do not match any of the parameters that take pipeline i
nput.
Error At line:1 char:88
Error + ... ame,Extension |unblock-file
Error + ~~~~~~~~~~~~
Error + CategoryInfo : InvalidArgument: (@{BaseName=ReadMe; Extensi
on=.
Error txt}:PSObject) [Unblock-File], ParameterBindingException
Error + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Com
mand
Error s.UnblockFileCommand
Error
Error unblock-file : The input object cannot be bound to any parameters for the
Error command either because the command does not take pipeline input or the inp
ut
Error and its properties do not match any of the parameters that take pipeline i
nput.
Error At line:1 char:88
Error + ... ame,Extension |unblock-file
Error + ~~~~~~~~~~~~
Error + CategoryInfo : InvalidArgument: (@{BaseName=Touc...Extensio
n=.v
Error ss}:PSObject) [Unblock-File], ParameterBindingException
Error + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Com
mand
Error s.UnblockFileCommand
Error
Error unblock-file : The input object cannot be bound to any parameters for the
Error command either because the command does not take pipeline input or the inp
ut
Error and its properties do not match any of the parameters that take pipeline i
nput.
Error At line:1 char:88
Error + ... ame,Extension |unblock-file
Error + ~~~~~~~~~~~~
Error + CategoryInfo : InvalidArgument: (@{BaseName=Touc...Extensio
n=.v
Error st}:PSObject) [Unblock-File], ParameterBindingException
Error + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Com
mand
Error s.UnblockFileCommand
Error
I know about the option to use System.Management.Automation, but unfortunately it doesn't work on Windows 8.1. The assembly dependencies are messed up with Windows 8.1.