chris
April 2, 2019, 12:19am
1
Does anyone code PADT scripts in VSCode?
I am trying to configure a build task to speed up my testing but I can’t see to get it working as I want.
Generally before importing my PADT into SCCM I like to test it manually, I do this using psexec -i -s to run the Deploy-Application.ps1 as the SYSTEM account so as to mimic how the SCCM agent runs.
Start-Process psexec.exe -ArgumentList ‘-i -s powershell.exe -executionpolicy bypass’ -WindowStyle Hidden -Verb runAs
I then simply execution .\Deploy-Application.ps1
So I was hoping to do something like this in a build task.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
{
“label”: “Deploy”,
“type”: “shell”,
“command”: “powershell”,
“args”: [
“-ExecutionPolicy”,
“Unrestricted”,
“-NoProfile”,
“-File”,
“${cwd}/Deploy-Application.ps1”
],
“group”: {
“kind”: “build”,
“isDefault”: true
}
}
]
}
chris
April 2, 2019, 2:47am
3
Worked it out…hoping this helps others.
// Available variables which can be used inside of strings:
// ${workspaceFolder} the path of the workspace folder that contains the tasks.json file
// ${workspaceFolderBasename} the name of the workspace folder that contains the tasks.json file without any slashes (/)
// ${file} the current opened file
// ${relativeFile} the current opened file relative to the workspace folder containing the file
// ${fileBasename} the current opened file's basename
// ${fileBasenameNoExtension} the current opened file's basename without the extension
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
// ${lineNumber} the current selected line number in the active file
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command"
]
}
}
},
"tasks": [
{
"label": "Install Interactive",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Install -DeployMode Interactive' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Install Non-Interactive",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Install -DeployMode NonInteractive' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Install Silent",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Install -DeployMode Silent' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Uninstall Interactive",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Uninstall -DeployMode Interactive' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Uninstall Non-Interactive",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Uninstall -DeployMode Non-Interactive' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Uninstall Silent",
"type": "shell",
"command": "Start-Process psexec -ArgumentList '-i -s powershell -NoExit -NoProfile -ExecutionPolicy Bypass ${cwd}/Deploy-Application.ps1 -DeploymentType Uninstall -DeployMode Silent' -Verb runAs",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
3 Likes
I have the same testing SCCM dilemma. Can you describe what file your editing here? Thanks.
long
October 25, 2019, 7:11am
5
I created this for easy testing - https://gallery.technet.microsoft.com/PADT-Script-Tester-Tool-9ab5707a#content
It runs with the user right…working on a edition that can minic system account
but what is this build task? it a vscode thing?