converting Batch File

Good afternoon all,

 I have a batch file which is hard coded by manufacture's specification to install their product; its application, "condor", is an HTC Processing application. Since this is an Open Source app, help from them is limited. There is no other way to perform an unattended installation according to their documentation. I was tasked with installing this condor application on a dozen or more systems and doing this manually takes quite a bit.

The batch file goes like this:

=====================================================================================================

@echo on
set ARGS=
set ARGS=%ARGS% NEWPOOL="N"
set ARGS=%ARGS% POOLNAME="POOLNAME"
set ARGS=%ARGS% RUNJOBS="N"
set ARGS=%ARGS% VACATEJOBS="Y"
set ARGS=%ARGS% SUBMITJOBS="Y"
set ARGS=%ARGS% CONDOREMAIL="administrator@domain.com"
set ARGS=%ARGS% SMTPSERVER="emailserver.domain.com"
set ARGS=%ARGS% HOSTALLOWREAD="*"
set ARGS=%ARGS% HOSTALLOWWRITE="*.domain.com"
set ARGS=%ARGS% HOSTALLOWADMINISTATOR="Server1.domain.com"
set ARGS=%ARGS% INSTALLDIR="C:\Condor"
set ARGS=%ARGS% INSTALLDIR_NTS="C:\Condor"
set ARGS=%ARGS% POOLHOSTNAME="Server1.domain.com"
set ARGS=%ARGS% ACCOUNTINGDOMAIN="domain.com"
set ARGS=%ARGS% JVMLOCATION="C:\Windows\system32\java.exe"
set ARGS=%ARGS% USEVMUNIVERSE="N"
set ARGS=%ARGS% STARTSERVICE="N"

msiexec /i %systemdrive%\Condor\installation\condor-7.4.4-winnt50-x86.msi %ARGS%  /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress

exit

======================================================================================================

I tried to convert the batch file into a PowerShell using a script I found in a Google search (http://powertoe.wordpress.com/2011/03/06/powerbits-5-installing-an-msi-via-winrm-remoting-with-powershell/). But when I try, it fails hanging forever doing nothing until I kill the process using "CTRL + C". I know I am doing something wrong or maybe it's not the best approach to follow. I also know this batch file can be called from a PowerShell script but I thought the batch file process could be converted into PowerShell since its using an MSI installer. My feeling is that it fails right at the part of passing the arguments. These args variable are meant to fill up the configuration file that the installation creates. This configuration file purpose is to adapt the application into my own environment.

The script I intent to test is:

=============================================================================================================

set ARGS=
set ARGS=%ARGS% NEWPOOL="N"
set ARGS=%ARGS% POOLNAME="POOLNAME"
set ARGS=%ARGS% RUNJOBS="N"
set ARGS=%ARGS% VACATEJOBS="Y"
set ARGS=%ARGS% SUBMITJOBS="Y"
set ARGS=%ARGS% CONDOREMAIL="administrator@domain.com"
set ARGS=%ARGS% SMTPSERVER="emailserver.domain.com"
set ARGS=%ARGS% HOSTALLOWREAD="*"
set ARGS=%ARGS% HOSTALLOWWRITE="*.domain.com"
set ARGS=%ARGS% HOSTALLOWADMINISTATOR="Server1.domain.com"
set ARGS=%ARGS% INSTALLDIR="C:\Condor"
set ARGS=%ARGS% INSTALLDIR_NTS="C:\Condor"
set ARGS=%ARGS% POOLHOSTNAME="Server1.domain.com"
set ARGS=%ARGS% ACCOUNTINGDOMAIN="domain.com"
set ARGS=%ARGS% JVMLOCATION="C:\Windows\system32\java.exe"
set ARGS=%ARGS% USEVMUNIVERSE="N"
set ARGS=%ARGS% STARTSERVICE="N"
$script = {
            $args = "-i c:\Condor\Installation\condor-7.4.4-winnt50-x86.msi %ARGS% /qn /norestart"
            [diagnostics.process]::start("msiexec.exe", $args).WaitForExit()
            do follow up stuff
}

invoke-command -ComputerName MachineName -scriptblock $script

======================================================================================================

Any help is much appreciated,

Thanks in advance,

Alex

February 15th, 2012 5:13pm

No, that won't work at all.  Powershell doesn't understand % environment variables.  You would have to set your arguments up as a hash table, and splat them to the -Arguments parameter of Invoke-Command.
Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 5:30pm

Quick splatting examples to add to what Grant said:

$param = @{ 
    Computername = 'testserver' 
    Class = 'Win32_operatingSystem' 
    ErrorAction = 'Stop' 
} 
Try { 
    Get-WmiObject @param 
} Catch { 
    Write-Warning ("{0}: {1}" -f $param['Computername'],$_.Exception.Message) 
}

$param = @{
    Computername = 'testserver'
    ScriptBlock = {Param ($arg) "This is a script block of stuff to do"; "These are the arguments yous supplied: {0}" -f $arg}
    ArgumentList = "List of arguments to supply to the command"
    ErrorAction = 'Stop'
}
Try {
    Invoke-Command @param
} Catch {
    Write-Warning ("{0}: {1}" -f $param['Computername'],$_.Exception.Message)
}

Some information about splatting can be found here:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/18/use-splatting-to-simplify-your-powershell-scripts.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/29/use-powershell-splatting-to-simplify-parameter-sets.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2011/09/25/configure-powershell-cmdlet-default-values-by-using-splatting.as

February 15th, 2012 6:03pm

Bigteddy,

Thanks for your reply but could you elaborate a little bit more on how to set the arguments up? The below makes more sense?

$script = {
            $args = "-i c:\Condor\Installation\condor-7.4.4-winnt50-x86.msi /qn /norestart"
            [diagnostics.process]::start("msiexec.exe", $args).WaitForExit()
            do follow up stuff
}

invoke-command -scriptblock $script  -argument @{NEWPOOL = "N";  POOLNAME="POOLNAME"; RUNJOBS="N"} -ComputerName MachineName

Thanks again,

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 6:11pm

invoke-command -scriptblock $script  -argument @{NEWPOOL = "N"; POOLNAME="POOLNAME"; RUNJOBS="N"} -ComputerName MachineName

That is exactly what I was talking about.  That's splatting

February 15th, 2012 6:14pm

But because you have so many arguments, use Boe's method of creating a hash table, and pass it to the Argument parmeter as such:

invoke-command -scriptblock $script  -argument @param

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 6:17pm

Thanks Grand and Boe for your help. I am going to read Boe's reference documentation and keep all posted about my progress,

Alex

February 15th, 2012 6:52pm

But because you have so many arguments, use Boe's method of creating a 'here-string', and pass it to the Argument parmeter as such:

invoke-command -scriptblock $script  -argument @param

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 7:19pm

Sorry, jv, quite right, don't know what I was thinking.  Will amend post to correct it.
February 15th, 2012 7:22pm

Sorry, jv, quite right, don't know what I was thinking.  Will amend post to c
Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 8:23pm

Ok, I am trying the following:

===========================================

$args_hash = @{
NEWPOOL="N"
POOLNAME="POOLNAME"
RUNJOBS="N"
VACATEJOBS="Y"
SUBMITJOBS="Y"
CONDOREMAIL="administrator@domain.com"
SMTPSERVER="emailserver.domain.com"
HOSTALLOWREAD="*"
HOSTALLOWWRITE="*.domain.com"
HOSTALLOWADMINISTATOR="server1.domain.com"
INSTALLDIR="C:\Condor"
INSTALLDIR_NTS="C:\Condor"
POOLHOSTNAME="server1.domain.com"
ACCOUNTINGDOMAIN="domain.com"
JVMLOCATION="C:\Windows\system32\java.exe"
USEVMUNIVERSE="N"
STARTSERVICE = "N"
}

$script  =  {
 $args = "-i c:\Condor\Installation\condor-7.4.4-winnt50-x86.msi /qn /norestart"
 [diagnostics.process]::start("msiexec.exe", $args).WaitForExit()
}

invoke-command -scriptblock $script -argumentlist @args_hash -ComputerName MachineName

==========================================================================

But fails everytime with the following error:

Invoke-Command : Missing an argument for parameter 'ArgumentList'. Specify a parameter of type 'System.Object[]' and try again.
At C:\script1\Condor_Scripts\Condor_installation\installing_software.ps1:26 char:50
+ invoke-command -scriptblock $script -argumentlist <<<<  @args_hash -ComputerName Mountairy
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
    + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.InvokeCommandCommand

Any ideas?

Thanks again,

February 15th, 2012 9:03pm

It looks like I was a bit hasty with the hash table solution.  When running the part of your batch file that builds up the %ARGS%, the result is a string, as such:

NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBM
ITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain
.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Ser
ver1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME=
"Server1.domain.com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\syste
m32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N"
 NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBMITJOBS="Y" CONDO
REMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain.com" HOSTALLOWR
EAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com"
 INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.
com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" US
EVMUNIVERSE="N" STARTSERVICE="N"

And I've just remembered that -Argument takes an array.  So perhaps the way to do this is to separate each of these argument with a comma, thus forming an array, and pass that to the -Argument of Invoke-Command.

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 9:26pm

Ok, I am trying the following:

===========================================

$args_hash = @{
NEWPOOL="N"
POOLNAME="POOLNAME"
RUNJOBS="N"
VACATEJOBS="Y"
SUBMITJOBS="Y"
CONDOREMAIL="administrator@domain.com"
SMTPSERVER="emailserver.domain.com"
HOSTALLOWREAD="*"
HOSTALLOWWRITE="*.domain.com"
HOSTALLOWADMINISTATOR="server1.domain.com"
INSTALLDIR="C:\Condor"
INSTALLDIR_NTS="C:\Condor"
POOLHOSTNAME="server1.domain.com"
ACCOUNTINGDOMAIN="domain.com"
JVMLOCATION="C:\Windows\system32\java.exe"
USEVMUNIVERSE="N"
STARTSERVICE = "N"
}

$script  =  {
 $args = "-i c:\Condor\Installation\condor-7.4.4-winnt50-x86.msi /qn /norestart"
 [diagnostics.process]::start("msiexec.exe", $args).WaitForExit()
}

invoke-command -scriptblock $script -argumentlist @args_hash -ComputerName MachineName

==========================================================================

But fails everytime with the following error:

Invoke-Command : Missing an argument for parameter 'ArgumentList'. Specify a parameter of type 'System.Object[]' and try again.
At C:\script1\Condor_Scripts\Condor_installation\installing_software.ps1:26 char:50
+ invoke-command -scriptblock $script -argumentlist <<<<  @args_hash -ComputerName Mountairy
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
    + FullyQualifiedErrorId : MissingArgument,Microsoft.PowerShell.Commands.InvokeCommandCommand

Any ideas?

Thanks again,

February 15th, 2012 9:38pm

I think there is some confusion on using splatting. You cannot use splatting against just a parameter, you use it against the command as the "splatting" contains each parameter with the assigned value (see my previous examples).

Also, you are not even using the ArgumentList correctly in your scriptblock. You need to define a Param () in the scriptblock so you can use the supplied ArgumentList data. ArgumentList takes an object or a collection of objects, not just an array.

Based on what I see from your beginning post using a batch file, the $Args should just be one long string, not a hash table or an array.

This is my take on it (Not Tested):

Pardon the very ugly code I am about to post...

$Data = 'NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBM ITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N" NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBMITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N"'
$Scriptblock = {Param ($ARG)
    msiexec /i %systemdrive%\Condor\installation\condor-7.4.4-winnt50-x86.msi $ARG  /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress
}
$param = @{
    Computername = 'MachineName'
    ScriptBlock = $Scriptblock
    ArgumentList = $Data
    ErrorAction = 'Stop'
}
Try {
    Invoke-Command @param
} Catch {
    Write-Warning ("{0}: {1}" -f $param['Computername'],$_.Exception.Message)
}

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 9:48pm

I think there is some confusion on using splatting. You cannot use splatting against just a parameter, you use it against the command as the "splatting" contains each parameter with the assigned value (see my previous examples).

Also, you are not even using the ArgumentList correctly in your scriptblock. You need to define a Param () in the scriptblock so you can use the supplied ArgumentList data. ArgumentList takes an object or a collection of objects, not just an array.

Based on what I see from your beginning post using a batch file, the $Args should just be one long string, not a hash table or an array.

This is my take on it (Not Tested):

Pardon the very ugly code I am about to post...

$Data = 'NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBM ITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N" NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBMITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailserver.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGDOMAIN="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N"' $Scriptblock = {Param ($ARG) msiexec /i %systemdrive%\Condor\installation\condor-7.4.4-winnt50-x86.msi $ARG /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress } $param = @{ Computername = 'MachineName' ScriptBlock = $Scriptblock ArgumentList = $Data ErrorAction = 'Stop' } Try { Invoke-Command @param } Catch { Write-Warning ("{0}: {1}" -f $param['Computername'],$_.Exception.Message) }		
February 15th, 2012 10:09pm

 

Boe,

Again thank you for your time and help. I tried your suggestion but it does not work either. It seems like the script is running but after a few seconds it stops, when I check the remote computer nothing has been done. When you pasted your code, the $data variable does not have anything separating the different arguments, is that how it is supposed to be or there is something missing that got lost when the code was copied. I see there is a warning catch you included in the code, where do you suppose to get those error messages? Thanks again.

Alex

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 10:44pm

 

Boe,

Again thank you for your time and help. I tried your suggestion but it does not work either. It seems like the script is running but after a few seconds it stops, when I check the remote computer nothing has been done. When you pasted your code, the $data variable does not have anything separating the different arguments, is that how it is supposed to be or there is something missing that got lost when the code was copied. I see there is a warning catch you included in the code, where do you suppose to get those error messages? Thanks again.

February 15th, 2012 11:05pm

Jvc,

My apologies if I did not include the code on my previous post. I would follow your suggestions. The only thing I have changed here it's the domain name for a generic name and the names of the target computer, e-mail server and server1. I forgot about removing the %system% variable and now I replaced it with the letter "C:\" which is where the drive where the installer is saved . I would try to drop the computer parameter and the splatting. I'll test locally and see what happen.

===================================================================================================

$Data = 'NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBMITJOBS="Y" CONDOREMAIL="aalas@domain.com" SMTPSERVER="emailservername.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGdomain="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N" NEWPOOL="N" POOLNAME="POOLNAME" RUNJOBS="N" VACATEJOBS="Y" SUBMITJOBS="Y" CONDOREMAIL="administrator@domain.com" SMTPSERVER="emailservername.domain.com" HOSTALLOWREAD="*" HOSTALLOWWRITE="*.domain.com" HOSTALLOWADMINISTATOR="Server1.domain.com" INSTALLDIR="C:\Condor" INSTALLDIR_NTS="C:\Condor" POOLHOSTNAME="Server1.domain.com" ACCOUNTINGdomain="domain.com" JVMLOCATION="C:\Windows\system32\java.exe" USEVMUNIVERSE="N" STARTSERVICE="N"'
$Scriptblock = {Param ($ARG)
    msiexec /i c:\Condor\installation\condor-7.4.4-winnt50-x86.msi $ARG  /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress
}
$param = @{
    Computername = 'Computer1'
    ScriptBlock = $Scriptblock
    ArgumentList = $Data
    ErrorAction = 'Stop'
}

Try {
    Invoke-Command @param
}

Catch {
    Write-Warning ("{0}: {1}" -f $param['Computername'],$_.Exception.Message)
}

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2012 11:29pm

jvr,

I am testing this tomorrow and reply to this same thread... If you don't hear from me after this post... I don't want anyone to think I don't appreciate your input.

Thanks for your help again ,

Alex

February 15th, 2012 11:33pm

jvr,

I am testing this tomorrow and reply to this same thread... If you don't hear from me after this post... I don't want anyone to think I don't appreciate your input.

Thanks for your help again ,

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 12:13am

I would try it like this first to be sure the parameters are actually correct.

Be carefull copying. It is all on one line.

$Scriptblock = {msiexec /i c:\Condor\installation\condor-7.4.4-winnt50-x86.msi NEWPOOL=N POOLNAME=POOLNAME RUNJOBS=N VACATEJOBS=Y SUBMITJOBS=Y CONDOREMAIL=aalas@domain.com SMTPSERVER=emailservername.domain.com HOSTALLOWREAD=* HOSTALLOWWRITE=*.domain.com HOSTALLOWADMINISTATOR=Server1.domain.com INSTALLDIR=C:\Condor INSTALLDIR_NTS=C:\Condor POOLHOSTNAME=Server1.domain.com ACCOUNTINGdomain=domain.com JVMLOCATION=C:\Windows\system32\java.exe USEVMUNIVERSE=N STARTSERVICE=N NEWPOOL=N POOLNAME=POOLNAME RUNJOBS=N VACATEJOBS=Y SUBMITJOBS=Y CONDOREMAIL=administrator@domain.com SMTPSERVER=emailservername.domain.com HOSTALLOWREAD=* HOSTALLOWWRITE=*.domain.com HOSTALLOWADMINISTATOR=Server1.domain.com INSTALLDIR=C:\Condor INSTALLDIR_NTS=C:\Condor POOLHOSTNAME=Server1.domain.com ACCOUNTINGdomain=domain.com JVMLOCATION=C:\Windows\system32\java.exe USEVMUNIVERSE=N STARTSERVICE=N
 /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress}

Do not let the line get broken.  Carefully edit any elements that need cahnging in notepad only.

Execute suchly: Invoke-Command -script $scriptblock

February 16th, 2012 12:26am

You can easily create a trznsform that would set all of those options.  Then execution only requires specifying the tr4anform name on teh commandline.

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 12:28am

I would try it like this first to be sure the parameters are actually correct.

Be carefull copying. It is all on one line.

$Scriptblock = {msiexec /i c:\Condor\installation\condor-7.4.4-winnt50-x86.msi NEWPOOL=N POOLNAME=POOLNAME RUNJOBS=N VACATEJOBS=Y SUBMITJOBS=Y CONDOREMAIL=aalas@domain.com SMTPSERVER=emailservername.domain.com HOSTALLOWREAD=* HOSTALLOWWRITE=*.domain.com HOSTALLOWADMINISTATOR=Server1.domain.com INSTALLDIR=C:\Condor INSTALLDIR_NTS=C:\Condor POOLHOSTNAME=Server1.domain.com ACCOUNTINGdomain=domain.com JVMLOCATION=C:\Windows\system32\java.exe USEVMUNIVERSE=N STARTSERVICE=N NEWPOOL=N POOLNAME=POOLNAME RUNJOBS=N VACATEJOBS=Y SUBMITJOBS=Y CONDOREMAIL=administrator@domain.com SMTPSERVER=emailservername.domain.com HOSTALLOWREAD=* HOSTALLOWWRITE=*.domain.com HOSTALLOWADMINISTATOR=Server1.domain.com INSTALLDIR=C:\Condor INSTALLDIR_NTS=C:\Condor POOLHOSTNAME=Server1.domain.com ACCOUNTINGdomain=domain.com JVMLOCATION=C:\Windows\system32\java.exe USEVMUNIVERSE=N STARTSERVICE=N
 /qb /lxv* c:\Condor\condor-install-log.txt /norestart REBOOT=ReallySupress}

Do not let the line get broken.  Carefully edit any elements that need cahnging in notepad only.

Execute suchly: Invoke-Command -script $scriptblock

February 16th, 2012 1:49am

I also agree with jv's suggestion that it seems you could set these MSI properties in a transform (mst) file and not have to worry about constructing such a long command-line string. (You can do this using Orca, but that's outside the purview of this specific forum.)

Bill

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 3:14pm

Jrv,

Your suggestion worked locally, the arguments were passed down correctly into the configuration file and the installation succeeded.

February 16th, 2012 4:35pm

Jrv,

Your suggestion worked locally, the arguments were passed down correctly into the configuration file and the installation succee

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 6:45pm

 

My apologies I didn't mean to mix concepts and confuse you all. I am executing the Invoke-Command with the purpose of installing this condor application because the msi is the only executable to make installations. When the installation completes successfully it generates a configuration file which is saved at the condor directory level. This config file saves all the variables that were passed down as arguments (NEWPOOL=N POOLNAME=POOLNAME RUNJOBS=N, etc) and the sole purpose of this config file is to tell the computer where the software is getting installed to act as a worker or submitter and that is part of my company condor pool since this application is meant for HTC (High Throughput Computer) or parallel processing. That is all.

The reason I didn't include that before and didn't elaborate to much about it was because I tried to keep my post short and concise in the installation process.  In the past when I had to do this installation I had to go manually on each machine and run a batch file the way I depicted at the beginning of the post. I thought if I did the install using PowerShell I could target more computers at the same time. Especially now that I was task with installing this software on 15+ and future computer I had at my disposition. Besides I wanted to script it so in case I am out of the office my co-workers could easily install it without me.

Anyways I ran the Invoke-Command -script $scriptblock -computer targetcomputer, and it failed. Unfortunately, I cannot use group policies because this is not a production application and only those prod users would need it, and certain machines we would be assigning as workers. Thanks again for your help.

The installation log is here:

===========================================================================================================

=== Verbose logging started: 2/16/2012  14:41:16  Build type: SHIP UNICODE 4.05.6001.00  Calling process: C:\WINDOWS\system32\msiexec.exe ===
MSI (c) (F4:3C) [14:41:16:918]: Resetting cached policy values
MSI (c) (F4:3C) [14:41:16:918]: Machine policy value 'Debug' is 0
MSI (c) (F4:3C) [14:41:16:918]: ******* RunEngine:
           ******* Product: c:\Condor_7_4_4\Condor\installation\condor-7.4.4-winnt50-x86.msi
           ******* Action:
           ******* CommandLine: **********
MSI (c) (F4:3C) [14:41:16:918]: Client-side and UI is none or basic: Running entire install on the server.
MSI (c) (F4:3C) [14:41:16:918]: Grabbed execution mutex.
MSI (c) (F4:3C) [14:41:16:933]: Cloaking enabled.
MSI (c) (F4:3C) [14:41:16:933]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (F4:3C) [14:41:16:933]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (64:C8) [14:41:16:949]: Running installation inside multi-package transaction c:\Condor_7_4_4\Condor\installation\condor-7.4.4-winnt50-x86.msi
MSI (s) (64:C8) [14:41:16:949]: Grabbed execution mutex.
MSI (s) (64:74) [14:41:16:949]: Resetting cached policy values
MSI (s) (64:74) [14:41:16:949]: Machine policy value 'Debug' is 0
MSI (s) (64:74) [14:41:16:949]: ******* RunEngine:
           ******* Product: c:\Condor_7_4_4\Condor\installation\condor-7.4.4-winnt50-x86.msi
           ******* Action:
           ******* CommandLine: **********
MSI (s) (64:74) [14:41:16:949]: Note: 1: 2203 2: c:\Condor_7_4_4\Condor\installation\condor-7.4.4-winnt50-x86.msi 3: -2147287037
MSI (s) (64:74) [14:41:16:949]: MainEngineThread is returning 3
MSI (s) (64:C8) [14:41:16:949]: User policy value 'DisableRollback' is 0
MSI (s) (64:C8) [14:41:16:949]: Machine policy value 'DisableRollback' is 0
MSI (s) (64:C8) [14:41:16:949]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (64:C8) [14:41:16:949]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (64:C8) [14:41:16:964]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2
MSI (s) (64:C8) [14:41:16:964]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (64:C8) [14:41:16:964]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\InProgress 3: 2
MSI (s) (64:C8) [14:41:16:964]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (s) (64:C8) [14:41:16:964]: Restoring environment variables

==========================================================================================================================

February 16th, 2012 7:50pm

jrv,

My apologies for the previous post, I had the msi location wrong and I just wanted to clarify I made a mistake when I ran the the Invoke-Command. . The installation succeeded after the right location was enter wth the  Invoke-Command -script $scriptblock -computer targetcomputer. I think the location got mixed up while I was doing copy/paste from the post to my command prompt.

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 8:21pm

jrv,

My apologies for the previous post, I had the msi location wrong and I just wanted to clarify I made a mistake when I ran the the Invoke-Command. . The installation succeeded after the right location was enter wth the  Invoke-Command -script $scriptblock -computer targetcomputer. I think the location got mixed up while I was doing copy/paste from the post to my command prompt.

February 16th, 2012 8:49pm

Yes it does. It works like a charm.

Alex

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 9:02pm

Yes it does. It works like a charm.

February 16th, 2012 9:12pm

Jvr,

Thanks for your help. I just need to figure out a way to put all that big line of parameters into a array or hash and get it to work.

Alex

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2012 9:20pm

Jvr,

Thanks for your help. I just need to figure out a way to put all that big line of parameters into a array or hash and get it to work.

February 16th, 2012 10:31pm

jrv,

Thanks for marking your reply as the correct answer to this post, I forgot and thank you all for your time and assistance

Sincerely,

Free Windows Admin Tool Kit Click here and download it now
February 20th, 2012 7:49pm

jrv,

Thanks for marking your reply as the correct answer to this post, I forgot and thank you all for your time and assistance

Since

February 20th, 2012 8:06pm

To run or convert batch files externally from powershell (particularly if you wish to sign all your scheduled task scripts with a certificate) I simply create a powershell script e.g deletefolders.ps1

Input the following into the script:

cmd.exe /c "rd /s /q C:\#TEMP\test1"

cmd.exe /c "rd /s /q C:\#TEMP\test2"

cmd.exe /c "rd /s /q C:\#TEMP\test3"

*Each command needs to be put on a new line calling cmd.exe again.

This script can now be signed and run from powershell outputing the commands to command prompt / cmd directly.

A much safer way then running batch files!
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2015 6:06am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics