I have some questions about a PowerShell script I need to write:
My script gets a list of servers' IP and it's output has to be the status of each server's WakeOnLan parameter.
The output also has to include the time it took my function to return all the statuses of all the servers.
Measure-Command does not work in this case, because my function is pretty long and it gets a list of hundreds IPs.
Does anyone know how to make my function write the following output:
"The total time of providing WakeOnLan status for ___(number) servers is ___(minutes).
After writing my function in some cases it can not run the Connect-HPEBIOS
command (when the output is more than one IP): It prints that it can not connect because of credentials (even though they are being written in my function correctly), but after trying to call my function with (only that specific IP - and not a list of IPs) the function works properly without printing an error about the credentials.
Does anyone have an idea what should I do in the cases where my output is more than one IP? How can I fix it?
One more question- Do I have to refer in my function to the different possibilities of different ILO versions? Can there be problems performing the Connect-HPEBIOS command in the different versions?
Thanks a lot!
Related
I'm working on a web app in Rust. I'm using Tokio Postgres, Rocket and Tera (this may be relevant).
I'm using the following to connect to my DB which doesn't fail in either case.
(sql_cli, connection) = match tokio_postgres::connect("postgresql://postgres:*my_password*#localhost:8127/*AppName*", NoTls).await{
Ok((sql_cli, connection)) => (sql_cli, connection),
Err(e) => return Err(Redirect::to(uri!(error_display(MyError::new("Failed to make SQLClient").details)))),
};
My query is as follows. I keep my queries in a separate file (I'm self taught and find that easier).
let query= sql_cli.query(mycharactersquery::get_characters(user_id).as_str(), &[]).await.unwrap();
The get characters is as follows. It takes a user ID and should return the characters that they have made in the past.
pub fn get_characters(user_id: i16) -> String {
format!("SELECT * FROM player_characters WHERE user_id = {} ORDER BY char_id ASC;", user_id)
}
In my main file, I have one GET which is /mycharacters/<user_id> which works. This GET returns an HTML file. I have another GET which is /<user_id> which returns a Tera template. The first works fine and loads the characters, the second doesn't: it just loads indefinitely. I initially thought this was to do my lack of familiarity with Tera.
After some troubleshooting, I put some printouts in my code, the one before and after the SQL call work in /mycharacters/<user_id>, but only the one before writes to the terminal in /<user_id>. This makes me think that Tera isn't the issue as it isn't making it past the SQL call.
I've found exactly where it is going wrong, but I don't know why as it isn't giving an error.
Could someone please let me know if there is something obvious that I am missing or provide some assistance?
P.S. The database only has 3 columns, so an actual timeout isn't the cause.
I expected both of these SQL calls to function as I am connected to my database properly and the call is copied from the working call.
I am trying to find the best way to use the notes field to set a shutdown order of virtual machines. At the moment, I have a note in my VM's as "Startup: X" where X is the number I want to use for startup, but the reverse being what I want for shutdown. The goal is to put this into a workflow so that machines complete their startup/shutdown before the next machine comes up.
Currently, I can get the info from the VMs by doing:
Get-VM | Where-Object {$_.Notes -contains "Startup:"} | Select-Object name,notes
It's my understanding that I want to put this into an object, then loop through that object based on the value after the ":" (e.g. 1, 2, 3, 4, 5, etc.) in either ascending or descending order. However, I'm not sure if that's the best method to work on this or not. All I know is that I want to look for the Startup: line in the VM Notes field, then use that alone to determine order. Some VMs might have other notes in them that I want to ignore, so I only want the Startup: string to show.
Could anyone give me some assistance? Or, let me know if I'm on the wrong path?
I have tried using multiple methods to parse, but I keep getting null errors that I cannot figure out. I'm fairly new to using PS in this way, so that doesn't help.
I am trying to build a subscriber function that goes like this:
Every user register his machine name to a list using
hostname:enlist .z.h
The function loops through the hostname list, creates connection and do some function {u:hopen(`:x:200;5000);u"somefunction[]"} each hostname
The only issue is .z.h is of a symbol where x should have no type in order to have this: u:hopen(`:HURNMW052:200;5000) instead of this u:hopen(`:`HURNMW052:200;5000)
The same thing happens using IPs ”.” sv string”h”$0x0 vs .z.a = "161.16.16.23" not 161.16.16.23
Any idea how I could cast those or other solutions to create a loop of handles?
You can use a string to open a connection. See below.
q)":",string[.z.h],":8009"
":homer:8009"
q)h:hopen(":",string[.z.h],":8009";5000)
q)h
3i
This reference on the kx wiki is useful for opening connections in kdb.
Working on a side project where I use a set of views to identify contention of records within an iSeries set of physical files.
What I would like to do once identified is pull the user profile locking the record, and then send a break message to their terminal as an informational break message.
What I have found is the QEZSNDMG API. Simple enough to use interactively, but I'm trying to put together a command that would be used in conjunction with QCMDEXC API to issue the call to QEZSNDMG and alert the user that they are locking a record.
Reviewing the IBM documentation of the QEZSNDMG API, I see that there are two sets of option parameters, but nothing as required (which seems odd to me, but another topic for another day). But I continue to receive the error "Parameters passed on CALL do not match those required."
Here are some examples that I have tried from the command line so far:
CALL PGM(QEZSNDMG) PARM('*INFO' '*BREAK' 'TEST' '4' 'DOUGLAS' '1' '1' '-4')
CALL PGM(QEZSNDMG) PARM('*INFO' '*BREAK' 'TEST' '4' 'DOUGLAS')
CALL PGM(QEZSNDMG) PARM('*INFO' '*BREAK' 'TEST' '4' 'DOUGLAS' '1')
Note: I would like to avoid using a CL or RPG program if possible but understand it may come to that using one of many examples I found before posting. Just want to exhaust this option before going down that road.
Update
While logged in, I used WRKMSGQ to see the message queues assigned to my station. There were two: QSYS/DOUGLAS and QUSRSYS/DOUGLAS. I then issued SNDBRKMSG with no affect on my workstation (IE, the message didn't break my session):
SNDBRKMSG MSG(TESTING) TOMSGQ(QSYS/DOUGLAS)
SNDBRKMSG MSG(TESTING) TOMSGQ(QUSRSYS/DOUGLAS)
I realized if I provide the workstation session name in the TOMSG parameter it worked:
SNDBRKMSG MSG(TESTING) TOMSGQ(*LIBL/QPADEV0003)
Using SNDBRKMSG was what I was looking for.
Some nudging in the right direction lead me to realize that the workstation session ID is located within QSYS2.RCD_LOCK in field JOB_NAME (job number/username/workstation).
Extracting the workstation ID allowed me to create a correctly formatted SNDBRKMSG command to QCMDEXC and alert the user that they are locking a record needed by another process.
I am new to rundeck and I wrote a basic script that will check if a file exists on a bunch of nodes ie it returns true or false. What I want to do next is then to parse whether the file exists or not and then send a single email with the results saying something like node x doesn't have the file, node y does have the file etc. My question is how can I aggregate the results from the other nodes so that I can loop through it and email it?
You can use a simple echo in your script to mention the existence of the file and then turn on Send Notification for the job, so that you can receive an email with the Log. This log will have the output of your script.