I can't get this working and from documentation and examples on the web i cannot work out why.
My code is simple, its just a script to which i want to pass a parameter, not every time. so i've laid the param section as thus
param(
[Parameter(Mandatory=$true)]
[string]$startOfName,
[ValidateRange(0,6)]
[int]$numberOfServers = 1,
[switch]$consecutiveNumbers
)
and im calling the scipt as follows.
.\Get-NextServerName.ps1 -startOfName servername -numberOfServers 5 -consecutiveNumbers
which gives me the lovely error message:
Get-NextServerName.ps1 : A parameter cannot be found that matches parameter name 'consecutiveNumbers'.
Can anyone see anything that I'm doing wrong?
This looks like being a bug in Powergui.Tried it from a command prompt and it worked first time. still won't work in Powergui. Think it might be related to the way it passes command line arguments from the shell pane to the script. Probably going to open a call to discuss, unless I find out im on a way old version.
Related
How can I pass flags to the InternetExplorer navigate method
Specifically, no cache or read or write to history
https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768360%28v%3dvs.85%29
What Ive tried so far, but just basing this off the BrowserNavConstants enum. Im not sure how one would pass more than one flag, nor if this is even taking effect, as my script seems to be pulling a page from previous execution.
https://learn.microsoft.com/en-us/previous-versions/dd565688(v%3Dvs.85)
$brFlgs = 4
$ie.navigate("my-url-here",$brFlgs )
I've been trying to use raster calculation in ipython for a tif file I have uploaded, but I'm unable to find the whole code for the function. I keep finding examples such as below, but am unsure how to use this.
gdal_calc.py -A input.tif --outfile=result.tif --calc="A*(A>0)" --NoDataValue=0
I then tried another process by assigning sections, however this still doesn't work (code below)
a = '/iPythonData/cstone/prec_7.tif'
outfile = '/iPythonData/cstone/prec_result.tif'
expr = 'A<125'
gdal_calc.py -A=a --outfile=outfile --calc='expr' --NoDataValue=0
It keeps coming up with can't assign to operator. Can someone please help with the whole code.
Looking at the source code for gdal_calc.py, the file is only about 300 lines. Here is a link to that file.
https://raw.githubusercontent.com/OSGeo/gdal/trunk/gdal/swig/python/scripts/gdal_calc.py
The punchline is that they just create an OptionParser object in main and pass it to the doit() method (Line 63). You could generate the same OptionParser instance based on the same arguments you pass to it via the command-line and call their doit method directly.
That said, a system call is perfectly valid per #thomas-k. This is only if you really want to stay in the Python environment.
This is the first time I'm encountering GetLayoutObjectAttribute and I am having serious issues with it. My variable $web won't set. I think it's because PD_WebV isn't the right object name to refer to, but I don't know how to find the right object name. I can't find the objects name when I hit Edit Layout, so does anyone know how to find an layout objects name?
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
If[$Web="done"]
#execute if statements
After Edit:
After some troubleshooting, I found out that PD_WebV is the right object name to refer and it's refered to correctly, so my new question is why doesn't the script go to the line If[$Web="done"] and how could I fix it? Ss my If statement not evaluating something it should be? Is my $web variable never set to done or is the issue something completely different? Would the problem possibly have to do with my WebDirect sharing settings? Any guidance would help. Thanks.
After, After Edit:
So now that my application is getting past Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")], the variable $web only equals <HTML></HTML>. Does anyone know a way, without using javascript, to test the inside of the html tags?
Also, I printed the bounds of the webViewer PD_WebV that I can't locate on the layout but am referring to in the script. The bounds that are printed are different each time I run the script. Is the usual or unusual? My source is also about:blank so it doesn't look like I'm sourcing from a URL
Is my $web variable never set to done or is the issue something
completely different?
If you're doing:
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
then the only time
$Web="done"
will return true is when the web page loaded into your web viewer contains exactly the string "done" (in practical terms, that's never).
I have already suggested in a comment that you test for:
PatternCount ( $webpage ; "</html>" )
This is assuming you want the subsequent steps to execute only after the page has finished loading. The entire script would look something like this:
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
Exit Loop If [ PatternCount ( $webpage ; "</html>" ) ]
End Loop
# execute statements
You might also want to add a counter to the loop and exit the script after n trials.
Ah, I reread your question.
To set the object name for your webviewer so that the GetLayoutObjectAttribute function works you need to set it in the Name field in the inspector when you have the webviewer selected.
e.g.:
After that your variable should populate.
Be aware
What it will populate with will be all of the html from the browser, i.e. not a boolean true/false liek your conditional suggests.
I'm not sure exactly what you're trying to accomplish, but to be able to determine a result from your web viewer you'll need to either parse the HTML to see if it's content contains what you're looking for or within the code you're setting the webviewer with, fire a javascript function that calls back to the FileMaker file using a FileMaker url.
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 have a problem with Net::Appliance::Session. I created a session, executed my command. After execution it prompts me some question (yes/no). I want to answer it but didn't find a way how to do it. Below you can see my trials:
$session->cmd($command);
$session->waitfor(Match=>'/.*yes*/');
$session->print("no");
$session->waitfor(Match=>'');
$session->print("y");
I don't know where is the problem. Accoding to CPAN documentations Net::Telnet have the method waitfor. But Session documentation tells that we can use waitfor(). Another thing said there is that the method "cmd" have a member Match which includes all the features of waitfor(). So I changed my code like below:
$session->cmd($command, Match=>'/.*yes*/');
$session->print("no");
Executing this reports below error:
Odd number of elements in hash assignment at
/usr/lib/perl5/vendor_perl/5.8.8/Net/Appliance/Session.pm line 245.
Is there any idea how can I do that? And why am I getting this error message?
Thanks in advance..
From the Net::Appliance::Session page at meta::cpan
To handle more complicated interactions, for example commands which prompt for confirmation or optional parameters, you should use a Macro. These are set up in the phrasebook and issued via the $s->macro($name) method call. See the Phrasebook and Cookbook manual pages for further details.
So you set up a macro (scripted call and response) in a phrasebook, and then tell your session to use that macro.