I usually execute scripts by filtering the workstations before selection, but this script that I've written is REALLY bad if it runs on a server. Is there a way to determine the OS of the target in the script and skip if it's a server?
My first thoughts are getRegistryValue() or testFileinDirectoryPath()
but I don't know exactly what I'm testing for. Any thoughts?
Thanks in advance!
-Dave in IL
Or simply use the step to check the variable #vmachine.osinfo#
If checkvar #vmachine.osinfo# contains "Server"
"Do Server stuff"
"Do Workstation Stuff"
You can use the "perform step on" procedure property to specify what OS you want it to be able to run on.
This powershell command also returns the Windows version:
(Get-WmiObject -class Win32_OperatingSystem).Caption
Check for "Server" in the response and exit if found.
Yet another option: Use the #vMachine.MajorVersion# checkVar function
There's one rare issue with using the #vmachine.osinfo# variable - the description is in the registry and can be modified!
We had a customer report that our procedure wasn't working on a specific machine that was indeed a server, but after investigating, we found that someone had modified the key to "Windows 2008 R2", removing the word "Server". Can't explain why it was done, but it broke the logic until that key was updated with the proper value.
We haven't changed our methods, but we do check for this any time things don't work as expected.