Create the PowerShell Commands in the .ps1 file.
For Example:
AppV_Client_Settings.ps1
'==========================================================================
'
' DESCRIPTION: To Add App-V client configuration settings using Powershell commands
'
' NAME: AppVClientConfiguration.vbs
'
' AUTHOR: Gnanamani P
'
' AMENDED :
'
' DATE : 11/12/2013
'
' USAGE: To Add App-V client configuration settings using Powershell commands
'
' PREREQ:
'
' COMMENT: Script should be called in Defferred execution in System context and in 64bit mode
'
'==========================================================================
Option Explicit
Dim objShell, objFSO
Dim strScriptPath, strWindir, ireturn, strCommand1, strCommand2
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strScriptPath=objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") &"\AppVClientConfig\5.0\"
strWindir = objShell.ExpandEnvironmentStrings("%windir%")
If objFSO.FileExists(strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe") Then
strCommand1= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe set-executionpolicy remotesigned -force"
ireturn = objShell.run(strCommand1,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: Powershell RemoteSigned Policy added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting Powershell RemoteSigned Policy. Return: " & ireturn
End if
strCommand2= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe –file " & Chr(34) & strScriptPath & "AppV_Client_Settings.ps1" & Chr(34)
ireturn = objShell.run(strCommand2,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: AppvClient Module, Client Configuration and Publishing server added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting AppvClient Module, Client Configuration and Publishing server. Return: " & ireturn
End if
Else
AddToMsiLog "Powershell.exe not found in the machine. App-V Client configurations are not added..."
End if
Private Sub AddToMsiLog(strMessage)
Dim objRecord, errMsiMessageTypeInfo
errMsiMessageTypeInfo = &H04000000
Set objRecord = Session.Installer.CreateRecord(1)
objRecord.StringData(1) = strMessage
Session.Message errMsiMessageTypeInfo, objRecord
Set objRecord = Nothing
End Sub
Include the AppV_Client_Settings.ps1 file here "C:\Program Files (x86)\AppVClientConfig\5.0\" in the MSI (for the above VBScript)
Include a Custom Action as below.
Content Disclaimer: Use my blog at your own risk. I’m not responsible for your use of the information contained in or linked from these web pages. This information is being given to you gratuitously and there is no agreement or understanding between you and me regarding your use.
For Example:
AppV_Client_Settings.ps1
Import-Module appvclient
Add-AppvPublishingServer -Name AppVServer -URL http://abc.local:8001
Set-AppvClientConfiguration -EnablePackageScripts 1
Create a VBScript to execute the .ps1 file using a Custom action.
For Example:
AppVClientConfiguration.vbs
'
' DESCRIPTION: To Add App-V client configuration settings using Powershell commands
'
' NAME: AppVClientConfiguration.vbs
'
' AUTHOR: Gnanamani P
'
' AMENDED :
'
' DATE : 11/12/2013
'
' USAGE: To Add App-V client configuration settings using Powershell commands
'
' PREREQ:
'
' COMMENT: Script should be called in Defferred execution in System context and in 64bit mode
'
'==========================================================================
Option Explicit
Dim objShell, objFSO
Dim strScriptPath, strWindir, ireturn, strCommand1, strCommand2
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strScriptPath=objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") &"\AppVClientConfig\5.0\"
strWindir = objShell.ExpandEnvironmentStrings("%windir%")
If objFSO.FileExists(strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe") Then
strCommand1= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe set-executionpolicy remotesigned -force"
ireturn = objShell.run(strCommand1,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: Powershell RemoteSigned Policy added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting Powershell RemoteSigned Policy. Return: " & ireturn
End if
strCommand2= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe –file " & Chr(34) & strScriptPath & "AppV_Client_Settings.ps1" & Chr(34)
ireturn = objShell.run(strCommand2,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: AppvClient Module, Client Configuration and Publishing server added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting AppvClient Module, Client Configuration and Publishing server. Return: " & ireturn
End if
Else
AddToMsiLog "Powershell.exe not found in the machine. App-V Client configurations are not added..."
End if
Private Sub AddToMsiLog(strMessage)
Dim objRecord, errMsiMessageTypeInfo
errMsiMessageTypeInfo = &H04000000
Set objRecord = Session.Installer.CreateRecord(1)
objRecord.StringData(1) = strMessage
Session.Message errMsiMessageTypeInfo, objRecord
Set objRecord = Nothing
End Sub
Include the AppV_Client_Settings.ps1 file here "C:\Program Files (x86)\AppVClientConfig\5.0\" in the MSI (for the above VBScript)
Include a Custom Action as below.
Content Disclaimer: Use my blog at your own risk. I’m not responsible for your use of the information contained in or linked from these web pages. This information is being given to you gratuitously and there is no agreement or understanding between you and me regarding your use.
No comments:
Post a Comment