Avatar of DevSupport
DevSupport

asked on 

passing parameters to powershell script

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!!
Powershell

Avatar of undefined
Last Comment
DevSupport
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of DevSupport
DevSupport

ASKER

Thank You so much oBdA! You are a life saver!
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo