rob3770 Posted May 11, 2011 Posted May 11, 2011 Im scripting a WMIC batch job which will run against a list of live servers and services, it will list out the required servers and output them too a CSV file. Now thats simple but the output needs to be auto sorted in a spreadsheet when opened, not like this (service,type,running,auto,etc).Is there a why for this to be done as there will be another one created that should compare the 2 spreadsheets and display the differances for powerdowns etc.Cheers guys and galsRob
Yzöwl Posted May 11, 2011 Posted May 11, 2011 There are always a host of ways of preforming tasks, however, you cannot change the output order from the WMIC command. You would need to use another method of obtaining the data or sort the data from the output prior to importing it.It is a two way process, I am not going to provide suggestions or solutions with insufficient information, so you'll need to fulfil that side of the process.
rob3770 Posted May 11, 2011 Author Posted May 11, 2011 Hi,This is the WMIC output in CSV format...Node,Caption,StartMode,State,StatusTSER-RKER-01,ASF Agent,Auto,Running,OKIn order to have them comma seperated within Excel then the app needs to be open and Text to Columns needs to be played with. This is the output im after...Node Caption StartMode State StatusTSER-RKER-01 ASF Agent Auto Running OK
allen2 Posted May 11, 2011 Posted May 11, 2011 Using double quote to enclose each value should solve then excel csv open problem. "TSER-RKER-01","ASF Agent","Auto","Running","OK"
rob3770 Posted May 11, 2011 Author Posted May 11, 2011 I can't enclose anything as its an automated output
Yzöwl Posted May 11, 2011 Posted May 11, 2011 You're still not really helping me much here!What are you wanting to be output?Is your requirement tab or space delimited as opposed to comma?Why are you using WMIC as opposed to other methods?What operating system(s)?What is the exact command line you are using?I asked for information and what you've supplied is very little. These things go a lot easier if we don't keep on providing you with answers then wait for you to give us reasons why it will not work for you. If you provide us with as much as possible to begin with it saves us wasting our time pointlessly.
rob3770 Posted May 11, 2011 Author Posted May 11, 2011 A simple command which displays certain services within a file listing of servers...wmic /output:"e:\scripts\service check\test\Services_Before.csv" /NODE:@"e:\scripts\service check\test\servers.txt" /failfast:on service where (name="clipsrv" or name="asfagent" or name="alg") get caption,startmode, state, status /format:csvThe output is within one excel cell and has to be manually edited via excel to seperate the comma delimiters, once this is done another script runs and produces an after csv file, this file is then compared to the first and any differances are highlighted.Im trying to automate the output so that the end user doesn't have to manually edit the file and when opened it will already be seperated.OS's are Windows 2000/2003/2008
allen2 Posted May 11, 2011 Posted May 11, 2011 (edited) Read there the solution to enclose values with double quote. Edited May 11, 2011 by allen2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now