I'm running into an issue with installing an MSI as a domain admin using powershell and batch scripts. Just to give a little bit of background, the environment I am in has UAC enabled. So regardless of being an admin or a standard user you need to always accept the UAC prompt to run an application. Now I am aware that there are registry tweaks and GPO's that I can enable to enableLUA, disable UAC, etc etc; but I'm trying to avoid making global changes like this to run the script (unless of course making these changes is a last resort)
Now the situation I am running in to is I am a Domain Admin. My org is planning on deploying PrintLogic as a printer solution, and we are trying to find the easiest way to deploy the client on all workstations. We don't have a software deployment app in the environment so I have to do this manually. This is why I am trying to take advantage of powershell and batch scripting to try and automate as much of the task as possible.
The powershell portion of the script basically is used to read encrypted password for the service account I will be using to install the software. The service account is also a domain admin so permissions shouldn't be an issue.
Now the software reads the credentials and stores them in a variable and then I pass those credentials through Start-Process. The issue I'm running in to is I can't get the installer to launch. I've tried several variations of the start-process command. And all of them either give me a access denied error (which makes no sense because as I mentioned the service account is domain admin), or I see the following warning "Warning: This command cannot be run due to the error: The directory name is invalid."
Here is the powershell script I am using (this version of the script has the msi installer programmed part of it so there are no batch scripts), however I also tried using startprocess to launch my install.bat file and then passing the credentials to the batch script as well and try installing it that way. Both methods give the same error above.
$global:adminCreds = $null
$global:path = (Split-Path $script:MyInvocation.MyCommand.Path)
function Authentication
{
#---------------------------------------------------
#Authenticate Admin Account using encrypted password
#---------------------------------------------------
#Variables
$global:AESKeyFilePath = $path + "\aeskey.txt"
$global:SecurePwdFilePath = $path + "\credpassword.txt"
$global:userUPN = "User"
#use key and password to create local secure password
$global:AESKey = Get-Content -Path $AESKeyFilePath
$global:pwdTxt = Get-Content -Path $SecurePwdFilePath
$global:securePass = $pwdTxt | ConvertTo-SecureString -Key $AESKey
#create a new psCredential object with required username and password
$global:adminCreds = New-Object System.Management.Automation.PSCredential($userUPN, $securePass)
}
function Run-SoftwareEscalated
{
Try
{
Start-Process "msiexec.exe" -Credential $adminCreds -Argument "/i `"$path\PrinterInstallerClient.msi`" /passive /norestart HOMEURL=https://url.domain.com AUTHORIZATION_CODE=123456789 /l* `"$path\logfile.txt`"" -Wait -WorkingDirectory $path
}
Catch
{
Write-Warning -Message "$($_.Exception.Message)"
}
}
#Run the authentication function to authenticate our session
Authentication
#Launch our main application
Run-SoftwareEscalated
My install.bat:
@echo off
cls
pushd "%~dp0"
::Launch our installer
start /w "" msiexec /i "%~dp0PrinterInstallerClient.msi" /passive /norestart HOMEURL=https://url.domain.com AUTHORIZATION_CODE=123456789 /l*v "%~dp0logfile.txt"