New to scripting and need help running powershell script to deploy software. (powershell blocked execution)

0

The following script was written for me. My problem is that when our remote deployment system executes the script, Powershell on the local machine will not run the script. It has no problem running .vbs though. Long story short, our remote deployment software copies this .zip file to all machines that are not connected to our domain. This script then is supposed to unzip the files into a specific location.

Without getting too much more complex, is there a way to convert this function into an easy .vbs or would there be a way to use a batch command to enable the powershell to execute this script on all workstations I need to?

Set oShell = CreateObject( "WScript.Shell" )
user=oShell.ExpandEnvironmentStrings("%UserName%")
comp=oShell.ExpandEnvironmentStrings("%ComputerName%")
USRPROFILE = oshell.expandenvironmentstrings("%UserProfile%")
Appdata = USRProfile & "\AppData\"
sZipFile = "C:\ProgramData\CentraStage\Packages\377fa3f4-6b60-4ec5-94b9-fc1716d53ea9#\vidistar.zip"
sTargetFolder = appdata
Dim oShellApp:Set oShellApp = CreateObject("Shell.Application")
Dim oFSO:Set oFSO = CreateObject("Scripting.FileSystemObject")
    'Create the target folder if it isn't already there
If not oFSO.FolderExists(sTargetFolder) Then
    oFSO.CreateFolder sTargetFolder
    wscript.echo sTargetFolder & "  Folder Has Been Created "
end if
'Extract the files from the zip into the folder
oShellApp.NameSpace(sTargetFolder).CopyHere oShellApp.NameSpace(sZipFile).Items

Mike

Posted 2015-01-29T19:28:24.503

Reputation: 1

Question was closed 2015-02-01T00:24:51.113

Answers

1

That code sample looks like VBScript, not PowerShell. Try running it with cscript.

Or, if your remote deployment system knows how to run .vbs files, just change the extension from .ps1 to .vbs.

Celery Man

Posted 2015-01-29T19:28:24.503

Reputation: 136

Also, on Vista or later, you probably don't want to drop the files into %userprofile%\appdata. Instead, appdtata\roaming or appdata\local would be more appropriate. – Celery Man – 2015-01-29T20:00:24.747

0

Here is a big time hint:

Get-Help Set-ExecutionPolicy

and

Get-Help about_execution_policies

The big question here is: are your target machines allowed to run unsigned scripts? PowerShell has different restrictions in place based on the session, and generally out of the box you will find that the policy is Restricted.

You can set the execution policy via Group Policy on domain-joined machines, and this is generally preferable.

blaughw

Posted 2015-01-29T19:28:24.503

Reputation: 214