Variable Name for MAC Adress
-
Friday, January 11, 2008 3:11 PM
I have been working on extending the console I have worked a xml to launch some vbscript.
</Executable>
</ActionDescription>
<ActionDescription Class="Executable" DisplayName="Force Reboot" MnemonicDisplayName="Force Reboot" Description="Reboots the selected machine">
<Executable>
<FilePath>wscript.exe</FilePath>
<Parameters>"C:\smsadmin\Scripts\SMS - Reboot.vbs" ##SUB:Name##</Parameters>
</Executable>All work well with ##SUB:Name## but I would like to pull the MAC Address for our wake on lan command
ActionDescription Class="Executable" DisplayName="Wake Up" MnemonicDisplayName="Wake Up" Description="Wake up the selected machine">
<Executable>
<FilePath>wscript.exe</FilePath>
<Parameters>"C:\smsadmin\Scripts\SMS - Wake up.vbs" ##SUB:MACAddresses##</Parameters>
</Executable>but the variable ##SUB:MACAddresses## is not working does anybody know the correct variable?
Thanks,
Paul
All Replies
-
Sunday, January 13, 2008 4:12 PMModerator
Just a thought, but have you tried using the ARR tag and then looping through the array instead of using the SUB tag? Maybe there are multiple MAC addresses, and the first one returned is NULL or something along those lines. I don't have a system to check right now on whether or not MACAddresses is a valid variable, but if I get a chance, I'll check for you.
-Jim.
-
Monday, January 14, 2008 10:35 PMModerator
I had a chance to spend some time on this today. Unfortunately, the child nodes under Collections return a list of SMS_CollectionMember objects, and that class does not have a property for MAC Address. That means you will not be able to use this relatively straight-forward approach to scripting something based off the MAC Address. To work around this limitation, you have a few options:
-
You could pass ##SUB:__SERVER##, ##SUB:__NAMESPACE##, and ##SUB:ResourceID## to your script. Then you would need to make a WMI connection to the provider (using the SERVER and NAMESPACE variables to initiate the connection, if remote), and run a query similar to SELECT MACAddresses FROM SMS_R_System WHERE ResourceID = wscript.arguments(2). Since this will return an array, you would need to loop through and find the MAC Address that you are interested in (probably the first one, and maybe only one, in most cases).
-
Alternatively, you could create new node XML to extend the console to have an "All Systems" node that returns a list of SMS_R_System objects. Then you could use your existing approach to pass ##ARR:MACAddresses## to your script and have your script parse that array for the value you want. I haven't tried this, but it should work in theory. However, it is probably not the best option if you have a large number of systems in your environment, as the view would have to enumerate every system in your database. Plus, it would probably be harder to find the system you're looking for if they are not grouped by collection or filtered in some way.
-
Instead of calling wscript.exe, call your own .NET assembly, which would natively know about the IResultObject that is being returned and would be able to reuse the existing connection to the provider to query additional information on the object. This approach is probably ok if you're a developer, but probably not the best option for anyone that is unfamiliar with .NET programming.
I realize this isn't a complete solution, but hopefully it at least gives you enough information to work with.
BTW, if you're ever wondering what properties are available for variable substitution for a given object in the console, you can pass ##SUB:__CLASS## to a script that just echos the value to the screen. Then you can connect to the provider with WBEMTEST and look for that class. Any PROPERTY that is listed for that class is available for variable substitution.
-Jim.
-
-
Tuesday, April 06, 2010 10:32 PM
I tried this "BTW, if you're ever wondering what properties are available for variable substitution for a given object in the console, you can pass ##SUB:__CLASS## to a script that just echos the value to the screen." and all I got was "SMS_Collection" output to the screen I was expecting all the various properties that are available for substitution?
Basically all I did is pass it this way:
cmd.exe /k ##SUB:__CLASS##
Is there a better way to do what you were suggesting?
Also i see above "##ARR:MACAddresses##" what is the difference between ARR and SUB?
Thanks,
Terry
-
Friday, April 16, 2010 6:28 AMModerator
I tried this "BTW, if you're ever wondering what properties are available for variable substitution for a given object in the console, you can pass ##SUB:__CLASS## to a script that just echos the value to the screen." and all I got was "SMS_Collection" output to the screen I was expecting all the various properties that are available for substitution?
Basically all I did is pass it this way:
cmd.exe /k ##SUB:__CLASS##
Is there a better way to do what you were suggesting?
As I mentioned in my previous post, this will tell you what class is being displayed in the list view. Then you have to open WBEMTEST (or your favorite WMI browser) and look for that class. Then you can get the list of available properties from there. Any non-array property listed for the class can be used in a ##SUB:... substitution statement.
Using your example of SMS_Collection, I can do the following:
- Open wbemtest on my site server and connect to the root\sms\site_<sitecode> namespace.
- Enumerate the classes recursively.
- Double-click the SMS_Collection class.
- Note the available properties. In addition to the standard __CLASS, __NAMESPACE, __PATH, etc., you'll also see CollectionID, CollectionRules, CollectionType, CollectionVariablesCount, Comment, etc. CollectionRules is an array data type, so it cannot be used in a ##SUB: statement. However, the other non-array properties can be used.
Also i see above "##ARR:MACAddresses##" what is the difference between ARR and SUB?
My understanding is that ARR can be used instead of SUB to get array data types. However, this information was given to me by one of our developers and I have not tried it first-hand, so I can't guarantee it works.- Proposed As Answer by Jim Dempsey [MSFT]Microsoft Employee, Moderator Friday, April 16, 2010 6:28 AM
- Marked As Answer by Jim Dempsey [MSFT]Microsoft Employee, Moderator Friday, April 16, 2010 4:41 PM
-
Thursday, April 12, 2012 3:28 PMDid you ever get anywhere with this? I have a similar dilemma where I need to be able to pass the FQDN from the Resource Names array to my scripts. I've tried to find information on using ARR to get at this data but to no avail.

