Closed mikemast01 closed 7 years ago
Please try to run the "run script remotely" script from powershell console. Define some simple command (such as "write-host test") to hardcode $script.
Is there a way to hardcode it so I can have users run the script for the web site, with the script hardcoded and they dont have to put it in the site.
Simply remove $script from parameter declaration. Line 71 t0 82 https://github.com/vmware/webcommander/blob/master/powershell/Windows/runScript.ps1#L82
I tried to specify the $script in the run script remoely ps1. after removing the parameter. Right below where objects.ps1 is called, i put in $script= " command to run"
And when I try to run from webcommander it just spins until the timeout value. I then uncomment the parameter and put $script back in as a parameter value and it runs fine.
I am trying to figure out why I cant specify the $script in the ps1 file, but when it is a parameter it works fine.
Any Ideas.
As I suggested in my first comment, run it in Powershell console directly and see what's the output there.
Sorry Jerry, I have not gotten back to this due to my workload.
I will get back to it and let you know, please don’t close this out.
Mike Masters | VMware Administrator | Emerson | 8000 W. Florissant Ave. | St. Louis | MO | 63136 | USA T +1 314.553.2542 | F + 1 314.553.1491 | M +1 314.502.8914 CompTIA | A+ , Net + , Sec. + VMWare | VCP 3,4,5 VCAP5-DCA MCITP | 2008 SA/VA
From: Jerry Liu [mailto:notifications@github.com] Sent: Friday, May 13, 2016 10:44 AM To: vmware/webcommander webcommander@noreply.github.com Cc: Masters, Mike [CORP/US] Mike.Masters@Emerson.com; Author author@noreply.github.com Subject: Re: [vmware/webcommander] Hard Code a script in "Run Script Remotely" (#165)
Please try to run the "run script remotely" script from powershell console. Define some simple command (such as "write-host test") to hardcode $script.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/vmware/webcommander/issues/165#issuecomment-219081306
Ok I am finally back on this. So the command I want to run is ; Get-CimInstance -ClassName win32_OperatingSystem | select lastbootuptime
I can run in powershell on the server and in the " run script remotely" , when I manually put it in.. but when I hard code the command into the script , web commander just spins and I get no result.
[parameter( HelpMessage="Script to run" )] [string] $script="Get-CimInstance -ClassName win32_OperatingSystem | select lastbootuptime",
I am wanting to setup a script for users that will give them info about the server or multiple servers and not have to log into every server on any server to run the powershell command it will be already setup, and the first thing is the uptime details...
Thanks for any ideas on this,
Mike
[parameter( HelpMessage="Script to run" )] [string]
PS C:\WebCommander\powershell\Windows> & '.\runScript - Copy.ps1'
cmdlet runScript - Copy.ps1 at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) vmName: evac.emrsn.org ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is an empty string. At C:\WebCommander\powershell\objects.ps1:1325 char:119
- CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSec
ureStringCommand
Success - connect to remote Windows machine 10.16.146.38 Success - run powershell script in VM
lastbootuptime PSComputerName RunspaceId
When I run the same command thru web commander website it will just spin and time out.
Is the script definition in one line or 2 lines? If 2, put it in 1 line and try again. If this still doesn't work, try $script="write-host test". Let me know the results.
I can type in a script in web commander on the "Run Script Remotely" and it works fine. When I try to hard code that script into the command it will not finish and times out after the time out period.
I have tried to set the variable $script and remove the variable, I have tried to set it up as a default input to the string if nothing is entered on the web page, and still cannot get it to run.
Is there a way to hard code a script and not have to type it in each time?