I know how to "draw" a window using powershell to display check boxes. However, that is about all I have been able to figure out. I want to display a list of virtual machines stored on an ESXI server (I can just set this statically as the list shouldn't change). What I need to figure out is how to make a check box cause vmrun to execute a power on for the machine. So basically I have four check boxes with say "VM01" , "VM02" , "VM03", "VM04". How can I have the checked boxes returned and say if VM01 & VM03 are checked turn on the machines. I have the power on scripts stored as variables
You need to add an event handler to the Click event. Add your code to the handler scriptblock.
$checkboxAll.add_Click($handler_checkboxAll_Click)
$handler_checkboxAll_Click=
{
if ($checkboxAll.Checked)
{
#do stuff if the box is checked
}
}
Related
I am trying to use Perform Script on Server function to improve speed of my database.
I make a very simple function but the "go to layout" function doesn't works. I used a field to make sure that the function is running on server.
"Main script":
perform script on server [Wait for completion; "PSOS script"]
"PSOS script":
set Field [Table::field ; Table::field & " PSOS script is running on server "]
go to layout["simpleLayout"]
"OnFirstWindowOpen"
If[LeftWords (Get (ApplicationVersion) ; 1) = "Server")]
set Field [Table::field ; Table::field & " OnFirstWindowOpen is running on server "]
Exit Script[];
End If
When I run the "Main script" the result of Table::field is:" OnFirstWindowOpen is running on server PSOS script is running on server", but I stay in the same layout.
My database is host in FMPhost.com cloud filemaker server 14.
Thanks.
What I think is confusing you is that when you perform a script on server, the server actually opens a separate instance of the database on the server.
It runs the startup script first, then your specified script.
You will not see any layout navigation in your local FileMaker as the layout change happens in the instance the server has opened.
You need to do all navigation scripting directly, for example by moving your go to layout step to your main script after the perform on server step.
More info on the function here.
Go to layout is PSOS compatible
Unless your PSOS script sets the global field, this field has to be on the first layout open.
Try to add another go to layout script step before you set the field through PSOS.
Another option - set the error capture on and parse the error back to your local script or check server log to track the issue.
go to layout["simpleLayout"]
Are you trying to pass a layout name into calculation? You need to either select it from the list or use layout number
Try adding "Go To Layout" Script step at the very beginning of the script, before "Set Field" navigating to the layout, where you need to set that field.
"PSOS script":
Go To Layout ["layoutName"]
set Field [Table::field ; Table::field & " PSOS script is running on server "]
go to layout["simpleLayout"]
I have spent a couple of hours search for a solution to disable my Azure Service Bus Topics using Powershell.
The background for this is we want to force a manual failover to our other region.
Obviously I could click in the Portal:
but I want to have a script to do this.
Here is my current attempt:
Any help would be great.
Assuming you're sure your $topic contains the full description, modify the status parameter in the array and then splat it back using the UpdateTopic method. I'm afraid I can't test this at present.
$topic.Status = "Disabled"
$topicdesc = $NamespaceManager.UpdateTopic($topic)
I don't think you'll need to set the entity type for the Status, nor do you require semi-colons after each line of code in your loop.
References
PowerShell Service Bus creation sample script (which this appears to be based off): https://blogs.msdn.microsoft.com/paolos/2014/12/02/how-to-create-service-bus-queues-topics-and-subscriptions-using-a-powershell-script/
UpdateTopic method: https://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.namespacemanager.updatetopic.aspx
Additional note: please don't screenshot the code - paste it in. I'd rather copy-and-paste than type things out.
I'm working on a rather simple script which should handle new values in the spreadsheet and then send emails to specified addresses. And I faced with the problem. My code is listed below:
function onEdit(e) {
//part of the code for checking e.range to process only updated values
sendEmail();
}
function sendEmail() {
// arguments are missed only for demo
GmailApp.sendEmail();
}
While I'm using "simple trigger", my function "sendEmail()" works only if I start it from script editor. I allowed sending emails on behalf of my at first time and then function works fine. But if I'm changing the value in the spreadsheet - function "onEdit(e)" processes new data but function "sendEmail()" does nothing.
I partly solved this problem by using project's triggers from "current project's triggers" menu. In that case, function "sendEmail()" works properly, but I have no access to the information about update.
For my purposes I could use just second way and find new values "manually" every time, but I wish to optimize this work.
So, my questions are:
Is the process I described above proper or I made a mistake
anywhere?
If process proper, is where a way to combine both cases?
Thanks!
You correctly understood that (as the docs say) simple triggers cannot send an email, because they run without authorization. An installable trigger, created via Resources menu, can: it has the same rights as the user who created the trigger. If it is set to fire on edit, it will get the same type of event object as a simple trigger does.
So, a minimal example would be like this, set to run "on edit":
function sendMail(e) {
MailApp.sendEmail('user#gmail.com', 'sheet edited', JSON.stringify(e));
}
It emails the whole event object in JSON format.
Aside: if your script only needs to send email but not read it, use MailApp instead of GmailApp to keep the scope of permissions more narrow.
I am trying to create a powershell script that pulls up a simple GUI form, displays "Loading..." in the title bar while it takes about 10-20 seconds to load the data, then finally change the title to "Please choose from the following options..." after loading.
I've been following this guide pretty much down to the letter. So far everything works, except for the fact that I get a "Parameter Count Mismatch" error when I execute this line:
$objListbox.BeginInvoke(
[Action[string]] { param($Message) $objListbox.Items.Add = $Message },
$MyMessage
)
Basically what I'm trying to do is load up about two thousand names into a multiselect listbox, then allow users to select the names they want to import elsewhere. So far everything works, I just have to hit continue on the Powershell ISE editor, but I'd like to get rid of this error all together.
BeginInvoke is rather older than generics in the .NET framework, and considerably older than the delegate Action<T>. Specifically you cannot pass an instance of Action<T> to BeginInvoke.
Try casting to System.Delegate instead.
I would like to run a few NirCmds when running an application such that it will change the primary display to the extended monitor, run the app and then switch back when finished. Ideally I would like to create this as a context menu option. Since this is using multiple commands I thought of using the script functionality from nircmd such as:
script "$folder.desktop/testscript.ncl"
with the script containing the lines I needed:
setprimarydisplay(2)
exec max "???.exe"
waitprocess ???.exe setprimarydisplay(1)
However I am not sure how to pass the process name from the context menu into the script or if this is even possible. Does anyone know how to do this or am I approaching this the wrong way?
I have the process location from the context menu as %1, so the issue is really just passing this into the script. Something like:
script "$folder.desktop/testscript.ncl" -%1