We help IT Professionals succeed at work.

passing parameters to powershell script

DevSupport
DevSupport asked
on
399 Views
Last Modified: 2017-04-28
I am using the following script to compare values between two files:

#--beginning of powershellscript compare.ps1

param([string]$nodeA = "nodeA", [string]$nodeB = "nodeB",  [string]$hanode = "hanode")
Add-Content "List of Non-Synchronized Users in HA Cluster $hanode"
compare-object (get-content $nodeA) (get-content $nodeB)

#--end of powershell

I want to use command prompt to send the name of files like this and get output in a file:

powershell.exe -File compare.ps1  -nodeA "mynodeA.txt" -nodeB "mynodeB.txt" -hanode "mycentralnode" -Out-File Output.txt -append

When I run the command in command prompt I get this error:

cmdlet Add-Content at command pipeline position 1
Supply values for the following parameters:

Please let me know how to fix the powershell script and the command prompt parameter passing so that it takes those two text files as input and display the Add-Content properly

Thank You so much and appreciate your help!!
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank You so much oBdA! You are a life saver!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.