[wpkg-users] powershell install command
Paul McGrath
J.P.McGrath at leeds.ac.uk
Mon Nov 11 19:36:43 CET 2013
Hi Daf,
thank you for replying. I've tried it a couple of ways now and I get the same problem. I can run the task in a admin 'CMD' prompt and the AppV package is published but it just wont work via WPKG.
I tried this as my 'install' line
<install cmd='%comspec% /c powershell -NonInteractive -Command "Import-Module Appvclient;Add-AppvClientPackage -Path C:\netinst\NotepadPlusPlus\NotepadPlusPlus.appv;Publish-AppvClientPackage NotepadPlusPlus" ' />
Nothing happened but if I type it in by hand it works without error. I decided to string the commands together with a delimiter ; and it works in a CMD prompt. I think it is about differences in what level WPKG is run at and what level the powershell runs at.
thanks
Paul
________________________________________
From: wpkg-users-bounces at lists.wpkg.org [wpkg-users-bounces at lists.wpkg.org] On Behalf Of Dafydd Jones (techneg.it) [dafydd at techneg.it]
Sent: 11 November 2013 17:06
To: wpkg-users at lists.wpkg.org
Subject: Re: [wpkg-users] powershell install command
On 9 November 2013 10:32, Paul McGrath <J.P.McGrath at leeds.ac.uk<mailto:J.P.McGrath at leeds.ac.uk>> wrote:
Is there an issue runningn powershell at System level?
Not that I have come across. I have started to use Powershell quite extensively in my Wpkg files with only minor issues, mainly to do with exit codes and quoting\escaping.
Here is an example that turns on Powershell remoting:
<?xml version="1.0" encoding="UTF-8"?>
<packages
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../xsd/packages.xsd" >
<package id="ps-remoting"
name="Enable Powershell Remoting"
revision="1"
reboot="false"
priority="10">
<check type="execute" path='powershell -NonInteractive -Command "if (Invoke-Command localhost {1}) {exit 0} else {exit 1}"' condition="exitcodeequalto" value="0"/>
<install cmd='powershell -NonInteractive -Command "Enable-PSRemoting -Force"'/>
</package>
</packages>
You can run script files as follows, but I have found that exit codes always report success despite the script commands failing.
<install cmd='powershell -NonInteractive -File "<path to .ps1>"'/>
You might find running powershell /? at the command prompt useful.
HTH,
Daf
More information about the wpkg-users
mailing list