Kaseya Community

Script request - deploy powershell

This question is not answered
Hi, I was about to create a script that detects if powershell is installed and installs it if required. Before I go to the bother, does anyone have this procedure already?
All Replies
  • PoSH 1.0? Here's one that I put together a while back that works well. I haven't updated it for x64, yet.

    <?xml version="1.0" encoding="utf-8"?>
    <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
    <Procedure name="Install PowerShell v1.0" treePres="3" id="81307274" folderId="11716119247213175919885148">
    <Body description="This script installs PowerShell silently. It will test for the existence of .NET Framework and install it, if necessary, before installing PowerShell.">
    <If description="This script installs PowerShell silently. It will test for the existence of .NET Framework and install it, if necessary, before installing PowerShell.">
    <Condition name="CheckRegistryValue">
    <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\Install" />
    <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />
    <Parameter xsi:type="StringParameter" name="Value" value="" />
    </Condition>
    <Then>
    <Statement name="WriteScriptLogEntry" continueOnFail="false">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 is already installed." />
    </Statement>
    </Then>
    <Else>
    <Statement name="UseCredential" continueOnFail="false" osType="Vista" />
    <Statement name="ExecuteScript" continueOnFail="false">
    <Parameter xsi:type="StringParameter" name="ScriptID" value="70974125" />
    <Parameter xsi:type="StringParameter" name="ScriptName" value="Install .NET Framework 3.5 SP1 (x86 &amp; x64)" />
    <Parameter xsi:type="StringParameter" name="TimeDelay" value="" />
    <Parameter xsi:type="EnumParameter" name="TimeUnit" value="Immediate" />
    </Statement>
    <Statement name="GetURL" continueOnFail="false" osType="XP">
    <Parameter xsi:type="StringParameter" name="URL" value="http://download.microsoft.com/download/7/3/4/7345bb7d-0b07-40e8-9480-5b8c55b9c8b7/WindowsXP-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="StringParameter" name="ResponseFileName" value="#vAgentConfiguration.agentTempDir#\WindowsXP-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="GetURL" continueOnFail="false" osType="2003">
    <Parameter xsi:type="StringParameter" name="URL" value="http://download.microsoft.com/download/d/e/7/de7cb629-73a3-49cc-b796-50dfaaf1b833/WindowsServer2003-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="StringParameter" name="ResponseFileName" value="#vAgentConfiguration.agentTempDir#\WindowsServer2003-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="GetURL" continueOnFail="false" osType="Vista">
    <Parameter xsi:type="StringParameter" name="URL" value="http://download.microsoft.com/download/4/b/8/4b8e4fac-bf73-49d0-8b98-ce1f58ba26b8/Windows6.0-KB928439-x86.msu" />
    <Parameter xsi:type="StringParameter" name="ResponseFileName" value="#vAgentConfiguration.agentTempDir#\Windows6.0-KB928439-x86.msu" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="ExecuteFile" continueOnFail="false" osType="XP">
    <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\WindowsXP-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="StringParameter" name="Arguments" value="/quiet /norestart" />
    <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="ExecuteFile" continueOnFail="false" osType="2003">
    <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\WindowsServer2003-KB926139-v2-x86-ENU.exe" />
    <Parameter xsi:type="StringParameter" name="Arguments" value="/quiet /norestart" />
    <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="ExecuteFile" continueOnFail="false" osType="Vista">
    <Parameter xsi:type="StringParameter" name="Path" value="%windir%\system32\wusa.exe" />
    <Parameter xsi:type="StringParameter" name="Arguments" value="#vAgentConfiguration.agentTempDir#\Windows6.0-KB928439-x86.msu /quiet /norestart" />
    <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
    </Statement>
    <Statement name="DeleteFile" continueOnFail="false" osType="XP">
    <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\WindowsXP-KB926139-v2-x86-ENU.exe" />
    </Statement>
    <Statement name="DeleteFile" continueOnFail="false" osType="2003">
    <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\WindowsServer2003-KB926139-v2-x86-ENU.exe" />
    </Statement>
    <Statement name="DeleteFile" continueOnFail="false" osType="Vista">
    <Parameter xsi:type="StringParameter" name="Path" value="#vAgentConfiguration.agentTempDir#\Windows6.0-KB928439-x86.msu" />
    </Statement>
    <Statement name="ExecuteFile" continueOnFail="true">
    <Parameter xsi:type="StringParameter" name="Path" value="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" />
    <Parameter xsi:type="StringParameter" name="Arguments" value="-noprofile Set-ExecutionPolicy RemoteSigned" />
    <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
    <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="False" />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="XP">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 for Windows XP has been installed." />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="2003">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 for Windows Server 2003 has been installed." />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="Vista">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 for Windows Vista has been installed." />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="98|Me">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 is not available for Windows 98 or Windows ME." />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="2000">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 is not available for Windows 2000." />
    </Statement>
    <Statement name="WriteScriptLogEntry" continueOnFail="false" osType="NT4">
    <Parameter xsi:type="StringParameter" name="Comment" value="Windows PowerShell v1.0 is not available for Windows NT4." />
    </Statement>
    </Else>
    </If>
    </Body>
    </Procedure>
    </ScriptExport>