commit 57a10e597dcd3aa506c0960019fc36433b30089d Author: jonas Date: Fri Feb 17 23:23:11 2023 +0100 First working version diff --git a/README.md b/README.md new file mode 100644 index 0000000..967475a --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +## IServ Package as alternative to iserv-windows-batch to run PowerShell scripts straight from the IServ portal server on a target Windows machine + +### Installing +- Put all files of this repo into `/srv/deploy/install/powershell-runner` on the IServ portal server +- Run chkdeploy as root/with sudo +- Create the directory that holds the PowerShell scripts: + - `# mkdir /srv/appdata/powershell-runner` +- Adjust directory permissions and ownership so admins can put script files there + - `# chown pcpatch:admins /srv/appdata/powershell-runner` + - `# chmod 0570 /srv/appdata/powershell-runner` diff --git a/control b/control new file mode 100644 index 0000000..638c563 --- /dev/null +++ b/control @@ -0,0 +1,14 @@ +[Product] +type: localboot +id: powershell-runner +name: PowerShell Script Runner +description: Dieses Paket führt PowerShell Scripte direkt von IServ aus +version: 1.0 +packageVersion: 1.0 +setupScript: install.ins + +[ProductProperty] +name: filename +description: Skriptname (ohne Endung) +default: start + diff --git a/install.ins b/install.ins new file mode 100644 index 0000000..a172c4a --- /dev/null +++ b/install.ins @@ -0,0 +1,44 @@ +[Initial] +Message=Starte PowerShell Script... +DefVar $ExitCode$ +DefVar $FileName$ +DefVar $Hostname$ +DefVar $KeyPath$ + +[Actions] +ShowBitmap "%ScriptPath%\logo.png" "PowerShell" +Sub_PrepInstall +DosInAnIcon_Setup +Sub_HandleExitCode +ExitWindows /Reboot + +[Sub_PrepInstall] +Set $FileName$ = GetProductProperty("filename", "start") +if ($FileName$ = "") + Set $FileName$ = "start" +endif +Set $Hostname$ = Lower(Trim(TakeString(0, GetReturnListFromSection("opsiservicecall_GetHostname")))) +Set $KeyPath$ = "\\" + $Hostname$ + "\appdata\%installingProdName%\" +if not(FileExists($KeyPath$+ $FileName$ + ".ps1")) + LogError "Fatal: File " + $FileName$ + ".ps1 not found." + IsFatalError +endif + +[opsiservicecall_GetHostname] +"method":"iserv_cfg" +"params":[ + "Hostname" +] + +[DosInAnIcon_Setup] +@echo off +pushd "\\iserv\appdata\%installingProdName%" +powershell -ExecutionPolicy Bypass -File "$FileName$.ps1" + +[Sub_HandleExitCode] +Set $ExitCode$ = GetLastExitCode +comment "DISM exit code: " + $ExitCode$ +if not($ExitCode$ = "0") + LogError "Fatal: DISM quit with exit code " + $ExitCode$ + IsFatalError +endif diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..722e2bb Binary files /dev/null and b/logo.png differ