Hi all, i’m attempting to install multiple msi at once via psappdep, but for some reason sccm doesnt want to deploy it like that, even though powershell works when executed standalone. Not a permissions issue.
The structure of files is like so
\server\folder\files - where all msi located (15+ msi’s)
\server\folder - root - where all scrip is located
if I manually run ps script it works fine, but when SCCM tries to execute this. I’m getting failed
this is my original part
#Get-ChildItem -Path '\\server\folder\files'-Filter *.msi | ForEach {
#Start-Process -Wait C:\windows\system32\msiexec.exe "/i `"$($_.FullName)`" /qn"
}
I was tried to come up with PSappdep friendly version but path is already used and its not actually msi path I after but variable (as in array in ForEach)
Get-ChildItem -Path '\\server\folder\files''-Filter *.msi | ForEach {
Execute-MSI -Action 'Install' -Path \\server\folder\files"
}
has anyone came up with better version which looks at folder, finds all msi, and then runs them one after other?
Is there a way to create array and then call from psapp deploy? Any hints are welcome.
Thanks
Try publishing an cmd.exe via the software center. Give a fake detections method so that you can keep the exe running while you test as SYSTEM account.
It would help the troubleshooting if you post the error message that you get.
thanks for reply Sven,
as for logs, which ones are you after? can you name few which I could check etc?
Just to add few cents - when I execute other apps to install, it works OK. with simple MSI and in Deployment option = (“Deploy-Application.exe” Install)
My problem (and maybe solution?) that when I execute script on itself it works fine, but from my limited exposure to psappdeploy there is whole bunch of background commands it relies on.
I have tried to just run the ps with Powershell.exe -ExecutionPolicy ByPass -File “Your-Scriptfilename.PS1” - that failed (dont see any erros which can explain why, or dont know where to look for ccm logs which explain the error.)
I have tried to jsut import standalone script (below) - with just that - that also failed. Maybe it doesnt like to call MSI from unc path? but then why does running scipt as admin work fine
#Get-ChildItem -Path '\\server\folder\files'-Filter *.msi | ForEach {
#Start-Process -Wait C:\windows\system32\msiexec.exe "/i `"$($_.FullName)`" /qn"
}
–Try publishing an cmd.exe via the software center. Give a fake detections method so that you can keep the exe running while you test as SYSTEM account.
is this just to see if application.exe can be deployed?
Well you are trying to read and execute files from another machine, but the account being used is local - SYSTEM. When you run it manually, you are logged in, presumably as a domain user, with access to the share/remote machine. Do you have share permissions setup correctly?
I see,
So if I make the following changes:
sccm files
content location \sccmserver\app\apptoinstall - where main appdepploy is located
content location \sccmserver\app\apptoinstall\msi - where msi located
then after content is downloaded locally it will create a random name in
C:\Windows\ccmcache
lets for sake called 2w (so full path for apptoinstall C:\Windows\ccmcache\2w
C:\Windows\ccmcache\2w\msi - where msi will be located.
How would I then instruct the script to look at this random folder (2w) without giving literal path in this script?
#Get-ChildItem -Path '[C:\Windows\ccmcache\[random letter]'-Filter *.msi | ForEach {
#Start-Process -Wait C:\windows\system32\msiexec.exe "/i `"$($_.FullName)`" /qn"
}
is there is a variable in psappdeploy I can use? I have tried $workdir or $dirFiles but issue is that msi files are inside the 2w\files
$dirFiles is variable that contains the full path to current toolkit’s Files folder. In your example it would be: C:\Windows\ccmcache\2w\Files
Get-ChildItem -Path "$dirFiles" -Filter '*.msi' | ForEach-Object {
# install each msi and wait til its installed and return the exit code. if the exit code is non-zero, return error and exit otherwise continue. to ignore an exit code, add parameter with the exit codes list or * for all. Example: -IgnoreExitCodes "1605,1603"
Execute-MSI -Action 'Install' -Path $_.FullName
}
Thanks, I’ll give that I try.
Also can you give me a tip how to better regression test apps with ps script without deploying them, then modifying the script (if there is an error) then update content sccm, rerun app eval and try to install this again. If there a quicker way?
Copy it to the machine, use PSexec to start powershell as SYSTEM. Then you can either run the script or deploy-application.exe from that powershell window to test it. You could run deploy-application.exe directly through psexec but you would have to restart psexec every time. Modify the script and test on the machine.
PSExec is free and by Microsoft - PsExec - Windows Sysinternals | Microsoft Docs
It creates a service, which runs under SYSTEM and then starts the exe you tell it to and then removes the service. SCCM agent has its own service and thats how it starts deployments as SYSTEM.
1 Like
this is an easy method to have your command prompt everywhere.
See screenshot below