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

  • Home
  • SEARCH
  • 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 6867243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:17:06+00:00 2026-05-27T03:17:06+00:00

I am very new to Powershell script. I am trying to run a powershell

  • 0

I am very new to Powershell script.

I am trying to run a powershell script from a cmd

powershell.exe Set-ExecutionPolicy Unrestricted
powershell.exe .\startup.ps1

I need two lines within powershell script.

%WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"

%WINDIR%\system32\inetsrv\appcmd.exe set app "WebRole_IN_0_VC/" /applicationPool:"VCPool"

Can I simply write it like this within the ps1 file?

& %WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"

Many Thanks

  • 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-27T03:17:07+00:00Added an answer on May 27, 2026 at 3:17 am

    Short answer, including a question: Why the hell does that need to be a PowerShell script?

    You can simply create a batch file containing

    %WINDIR%\system32\inetsrv\appcmd.exe add apppool /name:"VCPool" /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
    %WINDIR%\system32\inetsrv\appcmd.exe set app "WebRole_IN_0_VC/" /applicationPool:"VCPool"
    

    and run that directly instead of trying to figure out execution policies, etc.

    Furthermore, appcmd should probably be in your PATH, so you can run it directly without needing to specify the full path to the program.


    Longer answer, actually using PowerShell: There are two problems here.

    1. You want to run a PowerShell script without having the appropriate execution policy set. This can be done with

      powershell -ExecutionPolicy Unrestricted -File myscript.ps1
      
    2. You need to adjust environment variable usage within PowerShell scripts, as % is not used to expand environment variables there. So you actually need

      & $Env:WinDir\system32\inetsrv\appcmd.exe add apppool /name:VCPool /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated
      & $Env:WinDir\system32\inetsrv\appcmd.exe set app WebRole_IN_0_VC/ /applicationPool:VCPool
      

      Note also that you need an ampersand (&) before each line as a variable name in the beginning of a line switches into expression mode while you want to run a command, therefore needing command mode.

      Furthermore quoted arguments can be a bit of a pain in PowerShell. PowerShell tries quoting arguments when necessary and it’s not always obvious when things go wrong what actually comes out on the other end. In this case the easiest way is to not quote the arguments in any way whcih ensures that they come out correctly:

      PS Home:\> args add apppool /name:VCPool /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated
      argv[1] = add
      argv[2] = apppool
      argv[3] = /name:VCPool
      argv[4] = /managedRuntimeVersion:v4.0
      argv[5] = /managedPipelineMode:Integrated
      
      PS Home:\> args set app WebRole_IN_0_VC/ /applicationPool:VCPool
      argv[1] = set
      argv[2] = app
      argv[3] = WebRole_IN_0_VC/
      argv[4] = /applicationPool:VCPool
      

      However, if appcmd actually needs the quotes around the argument after a colon, then you need to quote the whole argument with single quotes and add the double quotes back in:

      & $Env:WinDir\system32\inetsrv\appcmd.exe set app WebRole_IN_0_VC/ '/applicationPool:"VCPool"'
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve some information about my hard drives using PowerShell (very new
Very new to PHP/programming in general, and I've been trying to run a PHP
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Im very new to SQL but need to write a query to do the
I am VERY new to ASP.NET. I come from a VB6 / ASP (classic)
I am really very new to powershell. I want to use powershell to read
Am very new to iPhone application development. Am adding the events to iCal from
I am very new to PowerShell scripting and was experimenting with Function . This
I'm very new to COM and Windows programming/scripting in general. What I was trying
im very new at javascipt (im php developer) so im really confused trying to

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.