How to create a command line package to Run.
At the startup or completion of your runbook you can run a script under SYSTEM.
You will need to package the script within a zip file for it to execute.
There are lots of options here, if you wish to run powershell to create a folder here is an example
Create a file called “cmdline.cmd” this will be run using command prompt. (it must be name this in all circumstances)
Put the following code in the script and save
start /WAIT "" "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File .\myscript.ps1
Then, create another file “myscript.ps1”
<#
.DESCRIPTION
This script will create a directory on the system
.AUTHOR
POwerSyncPro
.Version
0.1
#>
Start-Transcript -Path "C:\windows\temp\PSPScript.txt"
$diagPath = "C:\My_New_Folder"
# Create Directory
if(!(Test-Path -PathType container $diagPath))
{
New-Item -ItemType Directory -Path $diagPath
Write-Host "Folder created."
}else{
Write-Host "Folder exists."
}
Stop-Transcript
You will then zip these two files into a single compressed file, and upload it to the PSP runbook