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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:05:15+00:00 2026-05-25T10:05:15+00:00

I have to invoke a PowerShell script from a batch file. One of the

  • 0

I have to invoke a PowerShell script from a batch file. One of the arguments to the script is a boolean value:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -File .\RunScript.ps1 -Turn 1 -Unify $false

The command fails with the following error:

Cannot process argument transformation on parameter 'Unify'. Cannot convert value "System.String" to type "System.Boolean", parameters of this type only accept booleans or numbers, use $true, $false, 1 or 0 instead.

At line:0 char:1
+  <<<< <br/>
+ CategoryInfo          : InvalidData: (:) [RunScript.ps1], ParentContainsErrorRecordException <br/>
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,RunScript.ps1

As of now I am using a string to boolean conversion inside my script. But how can I pass boolean arguments to PowerShell?

  • 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-25T10:05:16+00:00Added an answer on May 25, 2026 at 10:05 am

    It appears that powershell.exe does not fully evaluate script arguments when the -File parameter is used. In particular, the $false argument is being treated as a string value, in a similar way to the example below:

    PS> function f( [bool]$b ) { $b }; f -b '$false'
    f : Cannot process argument transformation on parameter 'b'. Cannot convert value 
    "System.String" to type "System.Boolean", parameters of this type only accept 
    booleans or numbers, use $true, $false, 1 or 0 instead.
    At line:1 char:36
    + function f( [bool]$b ) { $b }; f -b <<<<  '$false'
        + CategoryInfo          : InvalidData: (:) [f], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,f
    

    Instead of using -File you could try -Command, which will evaluate the call as script:

    CMD> powershell.exe -NoProfile -Command .\RunScript.ps1 -Turn 1 -Unify $false
    Turn: 1
    Unify: False
    

    As David suggests, using a switch argument would also be more idiomatic, simplifying the call by removing the need to pass a boolean value explicitly:

    CMD> powershell.exe -NoProfile -File .\RunScript.ps1 -Turn 1 -Unify
    Turn: 1
    Unify: True
    
    • 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 uses du.exe ( Disk Usage originally from Sysinternals)
I have a fairly simple Psake build script (default.ps1) that calls Invoke-Psake from within
I have a powershell script that runs a console .exe application. The console application
I'm attempting to run a powershell script from C#. I have no problem passing
I am trying to run a external exe from a powershell script. This exe
I have an powershell script which is executing sql scripts from a given folder.
I have a custom PowerShell runspace from which I execute a script (simplified): Pipeline
I have the following powershell script $list = invoke-sqlcmd 'exec getOneMillionRows' -Server... $list |
I have this P/Invoke RegSetValueExW that sets the value to the registry key. in
I have a PowerShell script that needs to run normally, and also when invoked

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.