I'm trying to run a simple command line (PowerShell) that uses the pipeline once.
But the terminal appears to interpret what follows the pipe as a new command and not as something that will use the previous output.
This is the command line:
ASSIGN command = "powershell.exe Get-ADUser -LDAPFilter '(displayName=John Doe)' -Properties Department | Select Name, Department".
The output is:
'Select' is not recognized as an internal or external command, operable program or batch file.
Is there something that can be done in order to use the pipeline properly within OS-COMMAND?
Thank you all.
Try:
ASSIGN command = "powershell.exe ~"Get-ADUser -LDAPFilter '(displayName=John Doe)' -Properties Department | Select Name, Department~" ".
Hello,
The message that you are seeing seems to happen because cmd.exe (%ComSpec%) is processing two commands:
1) powershell.exe Get-ADUser -LDAPFilter '(displayName=John Doe)' -Properties Department
2) Select Name, Department
You would need to change your command to be a single command for powershell.exe.
Example:
DEFINE VARIABLE cCommand AS CHARACTER NO-UNDO.
cCommand = 'powershell.exe "Get-ChildItem C:\w* | Select Name"'.
OS-COMMAND VALUE(cCommand).
I hope this helps.
Try:
ASSIGN command = "powershell.exe ~"Get-ADUser -LDAPFilter '(displayName=John Doe)' -Properties Department | Select Name, Department~" ".
Hello,
The message that you are seeing seems to happen because cmd.exe (%ComSpec%) is processing two commands:
1) powershell.exe Get-ADUser -LDAPFilter '(displayName=John Doe)' -Properties Department
2) Select Name, Department
You would need to change your command to be a single command for powershell.exe.
Example:
DEFINE VARIABLE cCommand AS CHARACTER NO-UNDO.
cCommand = 'powershell.exe "Get-ChildItem C:\w* | Select Name"'.
OS-COMMAND VALUE(cCommand).
I hope this helps.