troubleshooting Question

How do I pass a 2-part parameter from one PS script to another?

Avatar of Alan Varga
Alan VargaFlag for United States of America asked on
Powershell
7 Comments1 Solution93 ViewsLast Modified:
Given that I have defined these variables in Switchboard-network adapters.ps1

[string] $PsFolder = "C:\Computer\Hardware\Network adapters"
[string] $ScriptToRun = "$PsFolder\EnableDisableNetworkAdapters.ps1"
[string] $ParmToUse = "-wired query"

and my parameter declaration is at the top of EnableDisableNetworkAdapters.ps1

Param(
      [string] $wireless,
      [string] $wired,
      [switch] $help
      )

why does this work from the console command line

&'C:\Computer\Hardware\Network adapters\EnableDisableNetworkAdapters.ps1' -wired query

but neither of these work from within Switchboard-network adapters.ps1?

&"$ScriptToRun" "$ParmToUse"

&($ScriptToRun) ($ParmToUse)

My error trapping in EnableDisableNetworkAdapters.ps1 produces

[-wired query] is an unrecognized parameter.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros