The secret was (also is), to brought all things i wanted (idea’s) to do, together. Then i only builded the architecture for it.
(Yes, maybe some call it a little virtual invention. )
Maybe same hard or easy like it “should be” in real life.
- User-GPO: Scheduled Task as S-1-5-18 (important not write “SYSTEM” write “S-1-5-18”)
- Trigger: “Any” user unlocks screen and “any” user login on machine. (for “full machine health control” - if you want)
- Action: run application: \\%your network share%\productive\MAINrun.exe:
(Background: I tried some hours to start a “Mainrun.ps1” with local powershell.exe directly and couldn’t got it worked. I also didn’t wanted to work with some cmd/bat. i wanted to do it only with powershell. So i sayed f*ck off and compiled it with a “PS1toEXE-Tool” because it works really fine with an “EXE”)
- Mainrun.ps1 code:
(Background: Normally no changes needed here, but if needed, you only have to change the “productive EXE”, filled with some other action, maybe you want delete the complete local deployment cache folder and delete the whole schedule, and all action will stop.)
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
Variablen
$CachePATHMainKit = "C:\deployment_cache\MainKit"
$targetfile = "$CachePATHMainKit\Deploy-Application.ps1"
$file = "\\%your network share%\productive\MainKit\Deploy-Application.ps1"
$PSNuGet = "C:\Program Files\PackageManagement\ProviderAssemblies"
check if local Deploy-Application.ps1, is not newer than the Deploy-Application.ps1 from the productive system. If so, she will be actualized. Else, do nothing. (This is for: “Client software change management”)
if ( test-path $targetfile ) {
if (!( (get-item $targetfile).LastWriteTime -gt (get-item $file).LastWriteTime ))
{
Copy-Item $file $targetfile -Recurse -force
}
else {}
}
check if the folder: “C:\deployment_cache\MainKit” not exists. If so , create folder and copy the whole “MainKit” from productive system to local cache. Else, do nothing. (This is for: “Client go first time under management”)
if (!(Test-Path $CachePATHMainKit))
{
New-Item -Path $CachePATHMainKit -ItemType Directory
Copy-Item -Path "\\%your network share%\productive\MainKit\*" -Destination $CachePATHMainKit -Recurse -force
}
check if the local folder: “$PSNuGet\NuGet\2.8.5.208” not exists. If so, create folder and copy the needed “Powershell 6 commandlet” from productive system to local system and install it in the local system. Else, do nothing. (Background: I like and need to use these newer powershell 6/7 functions later in the “Deploy-Application.ps1” to easier (don’t want use old WMI in Powershell and so on) get an client under management, especially if some older versions of apps needed to detect and uninstall, before install newest versions.)
if (!(Test-Path "'$PSNUGET\NuGet\2.8.5.208'"))
{
Copy-Item -Path "\\%your network share%\productive\nuget\*" -Destination $PSNUGET -Recurse -force
Import-PackageProvider -Name NuGet -RequiredVersion 2.8.5.208
}
now its time to change to local cache path and start the “Deploy-Application.exe” with “ServiceUI.exe” for use your function “Execute-Process” from here also (Also here was the best functionality for me, with your original EXE that also starts the PS1, instead of try some time to start PS1 directly)
cd "$CachePATHMainKit"
. .\AppDeployToolkit\AppDeployToolkitMain.ps1
Execute-Process -Path "$CachePATHMainKit\ServiceUI.exe" -Parameters "Deploy-Application.exe" -WindowStyle Hidden
end code
- file/folder content of “\\%your network share%\productive\MainKit”:
-
A copy from clean “Toolkit”-Folder from PSADT 3.8.3.
-
A copy from ServiceUI.exe in it. (From actual version of MDT,which i also use for base Operating System-Deployment, but thats another chapter).
-
The user modified “Deploy-Application.ps1” in it. (Explained in Part II)
- file/folder content of “\\%your network share%\productive\NuGet\2.8.5.208”:
- A copy of Microsoft.PackageManagement.NuGetProvider.dll
(Background: Got it from Import-Package
on Internet connected client)
So now i am nearly done with part 1 for today.
You all know now, how i prepared the “Main-Kit” for install and also upgrade, with a little implemented “intelligence” and ready for use.
- Part II with the content of Deploy-Application.PS1 will follow soon.
I would like to reveal two things.
-
All entries are only done in the “App_block” in the installation part of Deploy-Application.PS1. Install / patch to newer version / re-install / de-install
-
Each App (or what ever you want to do) has his “App_block” so you can easily use a template from copied “App_block”, paste it and fill it with your modified variable app data, to easily handle several apps and also to etablish an effective procedure for operating. If one App need a “change”, i only have to change the associated block, save the Deploy-Application.PS1 in productive path, and instantly every “schedule trigger” will go and get the actualized PS1 and do the changed steps from the associated App_block, without have influences to the other application blocks.