I am trying to do a procedure that will get a variable using the following:
Type of Value - SQL View Data
Value - #vAgentConfiguration.lastLoginName#
Name - LastLogged
Next step - Execute a shell command
Echo #lastLogged# >> c:\lastlogged.txt
When i ran this procedure i get:
Failed to create then step1, Get Variable.Error = Invalid Parameter, Script variable source specification of SQL View/Column is missing a slash
What am i doing wrong? Need help on this. Thanks.
SQL View Data - Use the GetVariable command with the SQL View Data option to create a new procedure variable and set it to the value of a dbo.SqlView.Column value. Use the format SqlViewName/ColumnName/mach.groupID or SqlViewName/ColumnName. If the optional machine ID is omitted, then the value for the agent executing the procedure is retrieved. If ColumnName contains a space, surround it with square brackets. Example: vSystemInfo/[Product Name]. See System > Database Views for a list of the SQL views and columns that are available.
just an extract from the help you can see the format is viewname/columnname
Thanks. i saw this one too. So your saying that i should use vAgentConfiguration/lastLoginname? instead of what i have there?
Actually, i read the help again and realized my mistake. Thanks.
i used constant value and #vAgentConfiguration.lastLoginName# - it worked.
As an alternative, you can also use the registry for retrieving last login:
Hi pords and anyone else confused by this.
The problem is you asked to call a sql value from a variable which was already calling the system value.
get Sql value for #vAgentConfiguration.lastLoginName# and store in LastLogged
get SQL value for "administrator" and store in LastLogged (assuming administrator was the last logged in user)
All you need to do is.
Echo #vAgentConfiguration.lastLoginName# >> c:\lastlogged.txt
and you will get what you needed.
There is often a lot of confusion between Get Variable - SQL View/Column, and the #viewName.columnName# syntax.
They are used separately, not together, only ever one of them. You do NOT need a Get Variable step of any kind to use #viewName.columnName#, as that is a 'variable' that already exists, it does not require creation. For example, create a new script and add a single step, say Write Procedure Log Entry, and put #vAgentConfiguration.agentTempDir# into the text field. Run the script on a machine and you'll see the agent working directory (i.e. C:\kworking) in the Script Log for the agent.
Lingario & Josh,
Thanks. I was able to make it work after trial and error cause i didnt see your response right away. Anyway, I do have another problem which i was able to create a work around. when i output the value to a file for example using - Echo #vAgentConfiguration.lastLoginName# >> c:\lastlogged.txt - for some reason, a white space is added at the end which would mess up result.
Any suggestion how i can accomplish this without the added white space? Thanks.
Yes, do this:
You do not need spaces surrounding the output operators.
Thanks!! So simple and yet easy to overlook. worked great!
Also when doing an echo you are always better off enclosing the content and the path in "" to use as delimiters just in case the content makes the command think it should break or the path contains spaces and acts up funny.
This will make sure you only input the content without extra characters like the space in end but I agree with SMason that you don't need the output operators
On another note Kaseya procedures now have a step "Write text to file" that will basically run the echo command for you