beckman55
asked on
PSINFO - revision of script - Computername, filter - .csv
The below script works great except it outputs in the following format:
Computer A:
Microsoft Office
Computer B:
Microsoft Office
The problem is once imported as a .csv it dumps the info all into column "A". Is there some way to get the output to be as such:
Computer A: , Microsoft Office
Computer B: , Microsoft Office
Thanks in advance.
Computer A:
Microsoft Office
Computer B:
Microsoft Office
The problem is once imported as a .csv it dumps the info all into column "A". Is there some way to get the output to be as such:
Computer A: , Microsoft Office
Computer B: , Microsoft Office
Thanks in advance.
@ECHO OFF
ECHO.
IF EXIST Temp RD /S /Q Temp
MD Temp
IF EXIST temp.txt DEL temp.txt
SET /P CLEAR_RESULTS=Clear Results.txt before starting new search? (y/n)
IF NOT %CLEAR_RESULTS%==n IF EXIST Results.txt DEL /Q /F Results.txt
SET /P CLEAR_LOG=Clear Log.txt before starting new search? (y/n)
IF NOT %CLEAR_LOG%==n IF EXIST Log.txt DEL /Q /F Log.txt
ECHO.
ECHO Please specify a software title to filter by (partial title names OK) or,
ECHO if none, please press the Enter key on your computer keyboard:
ECHO.
SET /P FILTER=
ECHO.
IF [%FILTER%]==[] GOTO UNFILTERED
IF NOT [%FILTER%]==[] GOTO FILTERED
PAUSE
EXIT
:UNFILTERED
CLS
ECHO.
ECHO Performing a software inventory on these machines
ECHO With no filter in place...
ECHO.
SETLOCAL
SET key=
FOR /F "Tokens=*" %%a IN ('type PCs.txt') DO SET line=%%a&call :PARSE
ENDLOCAL
GOTO END
:PARSE
::STRIP COMMAND CONTROL CODES
SET work=%line:"=%
SET work=%work::=%
SET work=%work:(=%
SET work=%work:)=%
SET work=%work:^&=%
SET work=%work:^|=%
SET work=%work:^>=%
SET work=%work:^<=%
SET work=%work:^%=%
SET work=%work:^!=%
SET work=%work:^;=%
::SAVE THE KEY
IF {%work:~0,1%}=={[} set key=%line%&goto :EOF
SET dw=%work:dword=%
IF "%dw%" EQU "%work%" goto :EOF
SET filename=%line%
SET substring=%filename:~33,30%
SET temp=%substring%
SET _string=%temp%
SET _endbit=%_string:*?=%
CALL SET _semiresult=%%_string:%_endbit%=%%
SET _result=%_semiresult:?=%
SET COMPUTERNAME=%line%
ECHO.
ECHO Checking to see if %COMPUTERNAME% is online...
PING -n 2 -w 500 %COMPUTERNAME% | FIND "Reply" > nul
IF %ERRORLEVEL%==0 GOTO STARTSCRIPT
IF %ERRORLEVEL%==1 GOTO NOREPLY
EXIT
:STARTSCRIPT
ECHO.
ECHO %COMPUTERNAME%:>>Results.txt
ECHO.>>Results.txt
FOR /F "TOKENS=* DELIMS= " %%b IN ('PSINFO \\%COMPUTERNAME% -s') DO ECHO %%b>>Results.txt
ECHO.>>Results.txt
EXIT /B
:FILTERED
CLS
ECHO.
ECHO Performing a software inventory on these machines
ECHO With the filter in place: %FILTER%
ECHO.
SETLOCAL
SET key=
FOR /F "Tokens=*" %%a IN ('type PCs.txt') DO SET line=%%a&call :PARSE
ENDLOCAL
GOTO END
:PARSE
::STRIP COMMAND CONTROL CODES
SET work=%line:"=%
SET work=%work::=%
SET work=%work:(=%
SET work=%work:)=%
SET work=%work:^&=%
SET work=%work:^|=%
SET work=%work:^>=%
SET work=%work:^<=%
SET work=%work:^%=%
SET work=%work:^!=%
SET work=%work:^;=%
::SAVE THE KEY
IF {%work:~0,1%}=={[} set key=%line%&goto :EOF
SET dw=%work:dword=%
IF "%dw%" EQU "%work%" goto :EOF
SET filename=%line%
SET substring=%filename:~33,30%
SET temp=%substring%
SET _string=%temp%
SET _endbit=%_string:*?=%
CALL SET _semiresult=%%_string:%_endbit%=%%
SET _result=%_semiresult:?=%
SET COMPUTERNAME=%line%
ECHO.
ECHO Checking to see if %COMPUTERNAME% is online...
PING -n 2 -w 500 %COMPUTERNAME% | FIND "Reply" > nul
IF %ERRORLEVEL%==0 GOTO STARTSCRIPT
IF %ERRORLEVEL%==1 GOTO NOREPLY
EXIT
:STARTSCRIPT
ECHO.
ECHO.>>Temp\%COMPUTERNAME%.txt
FOR /F "TOKENS=* DELIMS= " %%b IN ('PSINFO \\%COMPUTERNAME% -s') DO ECHO %%b>>Temp\%COMPUTERNAME%.txt
ECHO %COMPUTERNAME%:>>Results.txt
FOR /F "TOKENS=* DELIMS= " %%b IN ('FINDSTR /I "%FILTER%" Temp\%COMPUTERNAME%.txt') DO (
ECHO %%b>>Results.txt
)
ECHO.>>Results.txt
EXIT /B
:END
IF EXIST Temp RD /S /Q Temp
START Results.txt
EXIT
:NOREPLY
ECHO No Response From %COMPUTERNAME%>>Log.txt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure I understand the question? What would be in the complete.txt file?
~bp
~bp
ASKER
Nothing has to be in there. Just once the script finishes running on all the pc's then it will create a complete.txt file. This way the other admins will know if the script is done running and it's ok to pick up the "results" file from the server.
If there is a way to put the start time and end time of the script that would be cool. But that's icing on the cake.
If there is a way to put the start time and end time of the script that would be cool. But that's icing on the cake.
Just add this near the top of your script:
IF EXIST complete.txt DEL complete.txt
SET StartStamp=%DATE% %TIME%
And then where ever you want to indicate it ended do this.
SET StopStamp=%DATE% %TIME%
ECHO Start: %StartStamp%>complete.txt
ECHO Ended: %StopStamp%>>complete.txt
~bp
IF EXIST complete.txt DEL complete.txt
SET StartStamp=%DATE% %TIME%
And then where ever you want to indicate it ended do this.
SET StopStamp=%DATE% %TIME%
ECHO Start: %StartStamp%>complete.txt
ECHO Ended: %StopStamp%>>complete.txt
~bp
ASKER
Thank you very much
ASKER
Thank you