Forum Discussion
How deploy application using powershell script by intune ?
Hi community!
i'm trying to replace our anti virus Sophos by Checkpoint using script powershell.
The script works fine if i execute it with admin permission on the client but by Intune it's failed.
Uninstallation of Sophos works but not the MSI installation...
- Description
Start-Transcript "c:\sophos.log"
$SophosUninstallPath = "C:\Program Files\Sophos\Sophos Endpoint Agent\SophosUninstall.exe"
$rootPath = $PSScriptRoot
$rootPath = $rootPath + "\"
$CheckSophosExist = Test-Path $SophosUninstallPath
if ($CheckSophosExist){
Start-Process -FilePath $SophosUninstallPath -Wait -ArgumentList "--quiet"
}
$Arguments = "/i " + $rootPath + "EPS.msi" +" /quiet"
Start-Process -FilePath "msiexec" -wait -ArgumentList $Arguments
Stop-Transcript
File root (the setup file configured is Install_CheckPoint-EndPoint.ps1
Intune
Error
In IntuneManagementExtension.log
<![LOG[UnauthorizedAccessException occurs when unzipping Win32App user session 2, the exception is System.UnauthorizedAccessException: L'accès au chemin d'accès 'C:\Windows\IMECache\44e554fc-7cf7-48e1-ba88-445be166f5e2_1\EPS.msi' est refusé.
à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
à System.IO.Compression.ZipFileExtensions.ExtractToFile(ZipArchiveEntry source, String destinationFileName, Boolean overwrite)
à System.IO.Compression.ZipFileExtensions.ExtractToDirectory(ZipArchive source, String destinationDirectoryName)
à System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileName, String destinationDirectoryName, Encoding entryNameEncoding)
à Microsoft.Management.Services.IntuneWindowsAgent.AgentCommon.FileSystemWrapper.ExtractZipFileToDirectory(String sourceArchiveFileName, String destinationDirectoryName)
Is it the good way to do this?
Thank you!
8 Replies
- Mmmm... I only looked at the ime log you showed us... from there on I would say something is not going well as it does not find that MSI file.
So if it was me I would first just create a temp folder and copy the msi file to that location before uninstalling the the sophos client.
And after the uninstall, launcht that msi from the location you copied to instead of the imecache root folder- You don't actually need the MSI for uninstall
- JulianAF2380Brass Contributor
The uninstallation of Sophos working, it's the installation of the MSI the problem.... I edited the primary post 🙂
I did the same thing for a Customer of us, created a Win32 package with these 3 files (Install.cmd is empty because it was for uninstall only)
install.cmd
Uninstall.cmd
"C:\Program Files\Sophos\Sophos Endpoint Agent\uninstallcli.exe" /quiet
Detection.ps1
if (Test-Path 'C:\Program Files (x86)\HitmanPro.Alert\uninstall.exe') {
write-host Sophos present
exit 0
}
else {
write-host Sophos is not present
exit 1
}Most important thing is to remove the protection of the Sophos clients first so that it can be uninstalled.
- JulianAF2380Brass ContributorHi! I re installed the computer in English (it was in french) and now it's working. I need to make others tests on other computer in french to check if it was isolated problem.
- Ok, let us know 🙂