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 9152837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:09:07+00:00 2026-06-17T12:09:07+00:00

I wrote a powershell script that can be run from powershell like so: PS

  • 0

I wrote a powershell script that can be run from powershell like so:

PS C:> S:\MyScript.ps1 -a "select thing from table where name like 'name'"

I’ve stored it on a shared drive (S:), and I cannot run my powershell script in this form from either powershell or cmd.exe:

PS C:> powershell S:\MyScript.ps1 -a "select thing from table where name like 'name'"
C:\> powershell S:\MyScript.ps1 -a "select thing from table where name like 'name'"

I’ve also tried to run it bypassing the executionpolicy:

C:\> powershell -executionpolicy bypass -command S:\MyScript.ps1 -a "select thing from table where name like 'name'"

I’ve also tried to run it with the full UNC path (in all the forms above):

C:\> powershell \\MyServer\path\to\MyScript.ps1 -a "select thing from table where name like 'name'"

The only form that shows output is if I use a parameter that doesn’t require a string to be passed:

C:\> powershell S:\MyScript.ps1 -z

thing
-----
thing1
thing2
thing3

Does anyone know why this is? Is there some way I can pass a string to the script from cmd.exe?

  • 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-06-17T12:09:08+00:00Added an answer on June 17, 2026 at 12:09 pm

    Also note, that powershell.exe has a parameter -File which might be better for a file than -command. I’m not sure about the script parameters as they should be grouped in a string like Nick said. Just try Nicks solution and if that doesn’t work, try the -File parameter instead of -command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a powershell script that works fine if I run it from an
I've found a PowerShell script that can change the desktop wallpaper of my Windows
I wrote a simple powershell script that recursively walks a file tree and returns
I am trying to write a PowerShell script that can get pipeline input (and
I wrote a powershell script that connects to a remote machine with the intent
I wrote a simple powershell script that checks the number of tickets in a
I've created a PowerShell script that runs perfectly from the Management Shell. I'm trying
I'm trying to write a script in powershell that i can use to get
I have a test powershell V2 script that looks like this: function test_args() {
I'm newb in powerShell and in cmd, sorry. I'm trying write script that can

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.