K1000 agent / APP-V 5 / Powershell issues
Im trying to deploy app-v 5 apps via the k1000 agent. What I am doing is having the Kace Agent run a powershell script to add the virtual app with a command the looks something like this.
powershell.exe -executionpolicy RemoteSigned -noexit -file test.ps1
The script runs this command:
Add-AppvClientPackage "\\server\share\myapp.appv" | Publish-AppvClientPackage -DynamicUserConfigurationPath "\\server\share\myapp.xml" -global
Im having 2 problems with this process. The first problem appears to be that since the k1000 agent is running as system, the powershell script gets ran as system. Even though it is supposed to publish globally to all users, the app is not visible. running get-appvclientpackage as system shows the app, running get-appvclientpackage as any other user doesnt show the app which means it cant run.
The second problem is on an x64 OS. As far as I can tell, the kace client is only 32 bit. When it runs powershell, it runs the 32 bit version. The app-v client is x64. The 32 bit powershell can not import the app-v because its x64 and that means I cant even run the powershell script.
Has anyone figured out how to publish apps to all users via the Kace agent or figured out what to do about needing to run x64 powershell scripts from a 32 bit kace agent?
Thanks,
Dave
Answers (2)
Try this. Unfortunately I can't access my k1000 to test it.
Put the script to Run As User logged in to console
directory:
C:\sysnative\windowspowershell\v1.0
file:
powershell.exe
arguments:
-executionpolicy RemoteSigned -noexit -file "$(KACE_DEPENDENCY_DIR)\test.ps1"
Comments:
-
I was doing that as a software distribution and there is no option for who to run the script as that way. Im not sure I want to mix and match my software deployments with scripting even if the software deployment is a script.
I did figure out what the first problem was. I had added the -global in the powershell script to publish the app to all users however I forgot to reupload the script to Kace. Once I did that I also discovered I cant use the -DynamicUserConfigurationPath with the -global setting in appv but the app is working now.
Im still not sure what to do about the 64 bit issue. Im pondering using a vbs to determine which powershell to call and running it that way. - nimexx 11 years ago
Im going to share my solution to this in case anyone else has this issue.
If you are using the x64 app-v 5 client with Kace, you need to call the 64 bit version of powershell. To do this I wrote a vbs script that runs the correct powershell. Running powershell using %SystemRoot%\System32 would not work on a 64 bit OS because the Kace client would run the script in x86 mode and any call to system32 is redirected to syswow64, the x86 version of powershell will fail to run any commands for the 64 bit app-v client. You can use %SystemRoot%\sysnative to run 64 bit powershell however sysnative is only accessable when running a script in x86 mode on an x64 OS. The path doesnt exist on x86 OS or when using a 64 bit process on x64 OS. If you also need to run the script on an x86 OS or if you ever need to manually run that script on an x64 OS, you can not use just sysnative.
To work around this. my script checks to see where wscript was ran from. Either the Kace client called it ( which would always be syswow64) or its running in pure x86 or pure x64 more so you can run powershell normally.
script="\\server\share\app\app.ps1" If InStr(LCase(WScript.FullName),"syswow64") Then
'we are running wscript in 32 bit mode on a 64 bit OS (such as kace 32 bit client)
'we need to call 64 bit version of powershell
objShell.run("%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -executionpolicy RemoteSigned -windowstyle hidden -file """ & script & """"),0,true
else
'we are either running on a 32 bit OS or running as a 64 bit process on x64
'use normal path
objShell.run("%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy RemoteSigned -windowstyle hidden -file """ & script & """"),0,true
end if
The other issue I had was trying to deploy app-v apps globally with Kace. Since the script is being called with the Kace client, we are in system context and you have to use -global to deploy to other users or they wont see it. If you also need to use a custom deployment file, you need to do it during the Add instead of the Publish.
Add-AppvClientPackage "\\server\share\app\app.appv" -DynamicDeploymentConfiguration "\\server\share\app\app_DeploymentConfig.xml" | Publish-AppvClientPackage -Global
Hopefully someone will find this usefull.