'How to run a specific task in a powershell only in vscode

I am on windows 10 and my default shell in vscode is git bash which is used by all tasks.

For a specific task, I want to use powershell. Is this possible

        {
            "label": "sometask",
            "type": "shell",
            "command": "sam build",
            "group": "test"
        }


Solution 1:[1]

For the following worked.

https://code.visualstudio.com/docs/editor/tasks#_common-questions

{
"version": "2.0.0",
"windows": {
    "options": {
        "shell": {
            "executable": "cmd.exe",
            "args": [
                "/d", "/c"
            ]
        }
    }
},
...

Solution 2:[2]

How to configure a VSCode Task to run a PowerShell script in the integrated terminal

Run Code on integrated terminal Visual Studio Code

Integrated Terminal Tasks

Features In order to use this application, create a configuration file in your .vscode directory. This file will define the available tasks.

For example, it could look something like:

{
    "Task Name": {
        "cmd": "ps",            // The command you'd like to run in the terminal
        "args": ["-a"],         // Array of string arguments to the command
        "stealFocus": true,     // If this is true, focus will jump to the terminal right away
        "shellOptions": {}      // This allows you to override the default shell options described below for this specific task.
    },
    "Task 2:" {
        "cmd": {                // cmd and args can also vary based on platform, just like default shell.
            "default": "vi",
            "mac": "nano",
            "linux": "emacs"
        },
        "args": {
            "default": []
            "mac": ["-B"]
        }
    }
}

How do I configure a task to call a PowerShell script

Solution 3:[3]

The accepted answer is with cmd and it doesn't explain where it should be placed, this works with PowerShell:

{
    "version": "2.0.0",
    "tasks": [
       ...,
       {
            "label": "Name",
            "type": "shell",
            "command": "Some Command",
            "options": {
                "shell": {
                    "executable": "powershell.exe"
                }
            }
        }
    ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AhmedRana
Solution 2 postanote
Solution 3 jesus valdez