Executando um comando específico do PowerShell no CMD

1

É possível executar comandos simples do PowerShell em cmd, como "LS", por exemplo:

PowerShell -Command ls

Mas o que eu realmente quero executar é: [System.IO.Directory]::GetFiles("\.\pipe\")

Se eu passar pelo PowerShell, ele funciona e me fornece uma lista de canais.

Mas eu preciso disso usando CMD, então eu tentei:

PowerShell -Command [System.IO.Directory]::GetFiles("\.\pipe\")

Mas não vai funcionar:

    Missing ')' in method call.
At line:1 char:33
+ [System.IO.Directory]::GetFiles( <<<< \.\pipe\)
    + CategoryInfo          : ParserError: (CloseParenToken:Toke
   tContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

Eu tentei executar:

PowerShell -Command [System.IO.Directory]::GetFiles

e eu recebo:

MemberType          : Method
OverloadDefinitions : {static string[] GetFiles(string path), static string[] G
                      etFiles(string path, string searchPattern), static string
                      [] GetFiles(string path, string searchPattern, System.IO.
                      SearchOption searchOption)}
TypeNameOfValue     : System.Management.Automation.PSMethod
Value               : static string[] GetFiles(string path), static string[] Ge
                      tFiles(string path, string searchPattern), static string[
                      ] GetFiles(string path, string searchPattern, System.IO.S
                      earchOption searchOption)
Name                : GetFiles
IsInstance          : True

A minha pergunta é, como posso executá-lo com o parâmetro? ... obrigado antecipadamente!

    
por Hannan Maman 04.01.2016 / 10:42

0 respostas