Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3628178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:58:58+00:00 2026-05-18T23:58:58+00:00

I have a master powershell script as follows. It defines a single variable $V1

  • 0

I have a master powershell script as follows. It defines a single variable $V1 and then launches the sqlps that uses this variable. Since sqlps is itself a minishell it does not recognise $V1

$V1 = "asdasd"    

sqlps -NoLogo -Command {
            invoke-sqlcmd -Query $V1 -ServerInstance "SomeImstamce" -Database "SomeDatabase" -Username "SomeUsernName" -Password "SomePassword"
      }

I therefore updated the sqlps -Command block to expect a parameter as follows. However I am not sure how to pass the outer $V1 variable value to the inner sqlps -Command Block

$V1 = "RBIQHSAPPD049v.b2b.regn.net"

sqlps -NoLogo -Command {
            param ($SqlPsParam)
            invoke-sqlcmd -Query $SqlPsParam  -ServerInstance "SomeImstamce" -Database "SomeDatabase" -Username "SomeUsernName" -Password "SomePassword"
      }

There is syntax help on http://technet.microsoft.com/en-us/library/cc280450.aspx and I have tried many combinations but it doesnot seem to work.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:58:59+00:00Added an answer on May 18, 2026 at 11:58 pm

    oh figure it out atlast

    $V1 = "sdfsaf"
    $V2 = "safd"
    
    sqlps -NoLogo -Command {
                param ($SqlPsParam1, $SqlPsParam2)
                invoke-sqlcmd -Query $SqlPsParam  -ServerInstance "SomeImstamce" -Database "SomeDatabase" -Username "SomeUsernName" -Password "SomePassword"
          } -args $V1, $V2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master page that adds the jquery library via a registerclientscriptinclude: Page.ClientScript.RegisterClientScriptInclude(this.GetType(),
I have a master script that is attempting to execute additional scripts against a
I have master branch of the project. Then I want to add a new
I have a master table that I am inserting data into from an import
I have a master page called SampleMaster.master and this page contains a Repeater control
I have one master page which applies to all pages in this website. On
My powershell script takes the following parameter: Param($BackedUpFilePath) The value that is getting passed
i have master-content page scenario.I have a link button on content page. that redirects
I'm writing a powershell script that needs to push code to several git repositories
I have been trying to write a powershell program that checks to see if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.