Reputation: 29
I have seen many similar questions but none of them is related to the execution of a CMD command such as ipconfig
from a PS script (.ps1).
If you type those commands on the PS console they work fine but once on a script they don't, below you can see an example:
PS C:\Users\TestQro> adb devices List of devices attached PS C:\Users\TestQro> adb devices | Select-String -Quiet List True
returns True because the Select-String
finds the word "List" in the response of the command "adb devices" which is the expected behavior. But if I go and put the same command into a .ps1 script file PS answers when running:
PS C:\TesterInfo> ./TunnerApp.ps1 cmdlet Write-Output at command pipeline position 1 Supply values for the following parameters: InputObject[0]:
How should I type the normal CMD commands inside of a script? Why is it waiting for parameters on script but right in the console it works fine?
Upvotes: 1
Views: 10153
Reputation: 23
Based on your output there
PS C:\TesterInfo> ./TunnerApp.ps1
cmdlet Write-Output at command pipeline position 1
Supply values for the following parameters: InputObject[0]:
It looks like you have a Write-Output
statement somewhere in your PowerShell script that does not have any input. Look for an empty Write-Output
statement somewhere
Upvotes: 2
Reputation: 19634
What you're referring to as CMD commands are actually executables in the Windows
or System32
folders (or some other PATH
environment variable path). As such, you can call them like you would any executable using the call operator:
& "$Env:SystemRoot\System32\IPCONFIG.exe"
Upvotes: 0