MDT Task Sequence Steps to Install Cisco AnyConnect & ISE module with xml copy - mdt

I am trying to create MDT Task Sequence to Install Cisco AnyConnect with ISE Posture Module. Each application is having individual msi packages and which require "highest privilege" when installing the apps. I used "Start-Process" to trigger the application with misexec.exe cmd and each installation is recorded PowerShell Script.
Script INFO:-
Cisco AnyConnect Mobility VPN Client
Start-Process -FilePath msiexec -ArgumentList /i, anyconnect-win-4.10.05095-core-vpn-predeploy-k9.msi, /norestart, /passive, DISABLE_CUSTOMER_EXPERIENCE_FEEDBACK=1 -wait
Diagnostic and Reporting Tool (DART)
Start-Process -Filepath msiexec -ArgumentList /i, anyconnect-win-4.10.05095-dart-predeploy-k9.msi, /norestart, /passive -wait
Cisco Ise Posture
Start-Process -Filepath msiexec -ArgumentList /i, anyconnect-win-4.10.05095-iseposture-predeploy-k9.msi, /norestart, /passive -wait
Cisco Ise Compliance
Start-Process -Filepath msiexec -ArgumentList /i, anyconnect-win-4.3.2815.6145-isecompliance-predeploy-k9.msi, /norestart, /passive -wait
Copy SBL.xml to programdata
Copy-Item ".\inblr.ras.mavenir.com.xml." "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile" -Force -Confirm:$false -ErrorAction:SilentlyContinue
Copy iseposturecfg.xml to programdata
Copy-Item ".\ISEPostureCFG.xml." "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\ISE Posture" -Force -Confirm:$false -ErrorAction:SilentlyContinue
================================================================
Would need your support further integrating this into MDT task sequence.

Related

During Installation process of a software using Start-Process "msiexec.exe" ... -wait, how to fix error and continue the installation process?

For the installation of the "Self-Hosted Integration runtime software, using PowerShell command
Start-Process "msiexec.exe" "/i $path /quiet /passive" -Wait, error comes up for "DIAHostService" not having "LocalSystem" access.
I have the code to change the login to the LocalSystem ("sc.exe config "ServiceName" obj="LocalSystem") But How can I do this during the Installation Process, how do I catch the error and do the required change and continue for the installation automatically?
Code:-
param([string]$path, [string]$authKey)
function Install-Gateway([string] $gwPath)
{
# uninstall any existing gateway
UnInstall-Gateway
Write-Host "Start Gateway installation"
Start-Process "msiexec.exe" "/i $path /quiet /passive" -Wait
Start-Sleep -Seconds 30
Write-Host "Succeed to install gateway"
}
Since I am in no position to replicate what you are doing, take this generic approach as an example.
param([string]$path, [string]$authKey)
function Install-Gateway([string] $gwPath)
{
Write-Warning -Message 'Starting Gateway uninstallation'
UnInstall-Gateway
Try
{
'Starting Gateway installation'
Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i $path /quiet /passive" -Wait -ErrorAction Stop
Start-Sleep -Seconds 30
Write-Verbose -Message 'Gateway installation successful.' -Verbose
}
Catch
{
Write-Warning -Message 'AN error occurred'
$PSItem.Exception.Message
}
}
If you need to run this with a different user, then you need to add the RunAs as part of the Start-Process error logic. Yet using RunAs means starting a new Powershell instance. It will not run in the same process.
References
• PowerShell: Running Executables
Direct - Using the environment path or local folder
Invoke-Expression (IEX)
Invoke-Command (ICM)
Invoke-Item (II)
The Call Operator &
cmd /c - Using the old cmd shell
Start-Process (start/saps)
[Diagnostics.Process] Start()
WMI Win32_Process Create() Method
Stop-Parsing Symbol --%
see also:
'powershell start-process msiexec'
Powershell: Installing MSI files
'PowerShell start-process msiexec' try/catch
about_Try_Catch_Finally - PowerShell | Microsoft Docs
'PowerShell error preference'
Handling Errors the PowerShell Way | Scripting Blog
-ErrorAction and -ErrorVariable
You could also look at using PowerShell jobs for this use case.
start-process 'about PowerShell jobs'

Specifying complete installation option when running msi from powershell

I am trying to automate the installation of gstreamer on windows using powershell
I have the msi file downloaded, and am installing it as shown below
PS C:\Users\Administrator> $path = "C:\Users\Administrator\Downloads\gstreamer-1.0-devel-mingw-x86_64-1.18.0.msi";
PS C:\Users\Administrator> Start-Process -Wait -FilePath $path -Argument "/qn"
However, this does not get me the complete installation, because it is only selecting the default arguments from the installer.
I need to specify for it to perform the complete installation, how can I modify my arguments? So that it selects "complete" installation and not "typical" like it does by default
These should work:
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
I had the same problem, so I ran the Installer from power shell with and without the /qn argument and logged the process into two different files. Finally, I compared the result and I was able to find that for installing process using the UI it adds a property called INSTALLLEVEL, which is set to 1000 (don't know why this value yet). So, by adding the argument INSTALLLEVEL=1000 it installs the complete version.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"
I had tried below but it did not work
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
While this is working fine for me.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"

Silently install multiple exe installers in one folder in PowerShell

I've been learning powershell just for a bit and i was wondering if let's say for example in "D:\installers" folder where i have let's say 15 installers(all inno Setup) it would be possible to run a silent install of all of those exes?
So far i've learnt how to run just one installer on silent which works perfectly fine. I just dont know how i would do it with multiple exes
Start-Process -Wait -FilePath 'D:\Installers\Installer.exe' -ArgumentList '/silent' -PassThru just for one installer
$installers = get-childitem "D:\Installers" -Filter "*Driver*.exe"
foreach($inst in $installers)
{
Start-Process -Wait -FilePath ($inst.FullName) -ArgumentList '/silent' -PassThru
}
Get-Childitem can be used to get the installers, and with foreach you can go through the results
You may modify the path follow yours and copy it to powershell (ensure to run as administrator).
Powershell will run them in sequence one after another.
Start-Process -FilePath 'D:\Installers\Installer1.exe' -Wait
Start-Process -FilePath 'D:\Installers\Installer2.exe' -Wait
Start-Process -FilePath 'D:\Installers\Installer3.exe' -Wait

Can I check which Version my PS Script needs?

Sometimes when I'm writing a script on my Windows 10 Machine (PowerShell 5.0) I use commands, parameters or aliases which are not available on earlier versions of PowerShell, e.g the -persist parameter of new-psdrive is not available on PowerShell 2.0 which all of our Win7 machines use.
to set my #requires -version x statement correctly, I need to know if there are commands in my script which aren't available to earlier PowerShell Versions. When you wrote a code with 1000 lines it could be a little difficult to find unavailable commands in your script.
Is there a way to check this programmatically, other than just run the script in different PowerShell environments and see what's happening?
Have you considered developing on your Windows 10 machine but set your powershell profile to always run a powershell -version 2?
You'll launch powershell which will launch version 2 to develop in and if there are errors in the script you'll know when they're created and commands that would run in version 5 (or whatever version your Win10 machine has) would fail.
It should be noted that launching powershell like this:
powershell -version 2
will keep the logic the same and act like the version 2 powershell but the help file and output from commmands Get-Help will still show the version 5(or whatever) syntax that is true powershell version.
Setting your Powershell Profile:
http://www.howtogeek.com/50236/customizing-your-powershell-profile/
You can check the running version with
$PSVersionTable
This doesnt really answer your question
but i use the "Script Analyser" that comes with https://gallery.technet.microsoft.com/scriptcenter/Getting-started-with-57e15ada
I had previously thought that it would be good if it was enhance to check at different version levels. either output the minimum version for your script. or you specify a target version and it would tell you what was wrong.
We decided to make Powershell v.4 baseline for all systems. So I wrote a powershell script to ensure v.4 is install on all systems. This is set to run via GPO shutdown script under machine configuration.
IF ($PSVersionTable.PSVersion.Major -like "4*"){$StringToWrite | Out-File -FilePath $Logpath\PwrShl\Powershell_UpToDate_$hostname.log -Append; IF (Test-Path -Path $Logpath\PwrShl\Powershell_OutofDate_$hostname.log){Remove-Item $Logpath\PwrShl\Powershell_OutofDate_$hostname.log -Force}; exit}
IF (($PSVersionTable.PSVersion.Major -like "2*") -or ($PSVersionTable.PSVersion.Major -like "3*")){$StringToWrite | Out-File -FilePath $Logpath\PwrShl\Powershell_OutofDate_$hostname.log -Append}
if ($env:PROCESSOR_ARCHITECTURE -eq "x86"){
if (!(Test-Path C:\SchTsk\Temp\Windows6.1-KB2819745-x86-MultiPkg.msu)){Copy-Item "\\ad.dcpds.cpms.osd.mil\SYSVOL\ad.dcpds.cpms.osd.mil\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINE\Scripts\Startup\Windows6.1-KB2819745-x86-MultiPkg.msu" -Destination C:\SchTsk\Temp\Windows6.1-KB2819745-x86-MultiPkg.msu -Force}
}
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64"){
if (!(Test-Path C:\SchTsk\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu)){Copy-Item "\\ad.dcpds.cpms.osd.mil\SYSVOL\ad.dcpds.cpms.osd.mil\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINE\Scripts\Startup\Windows6.1-KB2819745-x64-MultiPkg.msu" -Destination C:\SchTsk\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu -Force}
}
IF ($env:PROCESSOR_ARCHITECTURE -eq "x86"){
Set-Location C:\SchTsk\Temp
if (!(Test-Path C:\SchTsk\Temp\Windows6.1-KB2819745-x86-MultiPkg.msu)){exit}
expand -F:* .\Windows6.1-KB2819745-x86-MultiPkg.msu C:\SchTsk\Temp
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2872035-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2872047-x86.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2819745-x86.cab /NoRestart' -Wait
}
IF ($env:PROCESSOR_ARCHITECTURE -eq "amd64"){
Set-Location C:\SchTsk\Temp
if (!(Test-Path C:\SchTsk\Temp\Windows6.1-KB2819745-x64-MultiPkg.msu)){exit}
expand -F:* .\Windows6.1-KB2819745-x64-MultiPkg.msu C:\SchTsk\Temp
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2809215-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2872035-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2872047-x64.cab /NoRestart' -Wait
Start-Process dism.exe -ArgumentList '/online /add-package /PackagePath:C:\SchTsk\Temp\Windows6.1-KB2819745-x64.cab /NoRestart' -Wait
}
Are network speed is kind of crapy and I was having problems with it trying to continue to run and the file not be existant. So I simply had it exit if the file isn't there to extract and install. Since it takes a restart, shutdown script made the most since. This was pretty successful for me, had a few trouble childs.

Installing AppFabric 1.1 with PowerShell DSC results in modal dialog error

I'm trying to automate the installation of AppFabric 1.1 on a Windows 2012 R2 server using PowerShell DSC. This is actually part of me trying to automate the SharePoint Foundation install and configuration, but AppFabric 1.1 is a pre-requisite. Below is a snippit from my DSC config script:
Script InstallSharePointPreRequisites
{
GetScript = { Return "InstallSharePointPreRequisites" }
TestScript = {$false}
SetScript = {
Start-Process -FilePath 'c:\temp\SharePoint\pre\MicrosoftIdentityExtensions-64.msi' -ArgumentList '/qn' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\setup_msipc_x64.msi' -ArgumentList '/qn' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\sqlncli.msi' -ArgumentList '/qn' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\Synchronization.msi' -ArgumentList '/qn' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\WcfDataServices.exe' -ArgumentList '/quiet' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\appfabric\setup.exe' -ArgumentList '/i cacheclient","cachingService","CacheAdmin /gac /l c:\temp\appfabric.log' -Wait | Write-verbose
Start-Process -FilePath 'c:\temp\SharePoint\pre\AppFabric1.1-RTM-KB2671763-x64-ENU.exe' -ArgumentList '/quiet' -Wait | Write-verbose
}
DependsOn = "[File]GetSharePointFiles"
}
I know....the "TestScript = $false" is bad form, but I'm just trying to get the install to run at this point. :)
Anyway, when the DSC run get to the appfabric\setup.exe it's throwing the following exception:
"{"Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."}"
When I run the Start-Process line from a normal PS prompt it installs fine and doesn't show a visible modal dialog box. I've also tried using the AppFabric setup EXE with similar switches with the same result. I'm sort of at a loss here. Has anyone else been able to install AppFabric 1.1 using PowerShell DSC? Or SharePoint Foundation 2013 for that matter? If so, how? I haven't been able to find good documentation on this scenario yet.
Thanks,
A
I solved this problem. First, there was a typo in my script. The app fabric setup line had CachAdmin rather than CacheAdmin (was missing the 'e' in cache). It took me some time and writing it a few more times to figure that out. After setting that, it is installing fine. Darn, old eyes and fat fingers... Thanks for looking. :)
A