SCCM
is often considered a delivery mechanism using which IT Teams can deliver their
intelligence thru software, script etc to clients around, based on what is
required by business. Recently our project demanded us to come up with a script
that will be deployed thru SCCM to find and delete certain older versions of
our LOB apps on each of the local drives on clients. Though I am not an expert
at scripting, but do have passion for scripting /automation as they benefit in increased
productivity. Ok, this passion drives me to find and build script (from net,
sometimes) and, would like to share below what I used for above said
requirement just in case if you will find it useful
@ECHO
OFF
Echo
Starts now on %computername% >> c:\windows\temp\%computername%.log
date
/t && time /t >> c:\windows\temp\%computername%.logwmic path win32_logicaldisk where drivetype=3 get caption | findstr : > c:\windows\temp\drvs.txt
for /f %%v in (c:\windows\temp\drvs.txt) do call :DelFunction %%v
:DelFunction
%1
cd\ >> c:\windows\temp\%computername%.log
Echo Starts now on %computername% and %1 drive >> c:\windows\temp\%computername%.log
date /t && time /t >> c:\windows\temp\%computername%.log
del LOBApps1.exe /s /Q /f >> c:\windows\temp\%computername%.log
del LOBDepend.exe /s /Q /f >> c:\windows\temp\%computername%.log
Echo Ends now on %computername% and %1 drive >> c:\windows\temp\%computername%.log
date /t && time /t >> c:\windows\temp\%computername%.log
copy c:\windows\temp\%computername%.log \\SCCMDP\FilesDelete$ /Y
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000002}" /NOINTERACTIVE
PS: Innovate as much as possible, leveraging SCCM Capabilities to transform your IT environments and you will rock !!!
Cheers,
Vasu Miriyala
Hi
ReplyDeleteI find this script very useful and i want to use it just to find and report to SCCM if a file exists in any of the computer drives.
So if I change the two lines where you delete your files by the following two:
if exists file1.exe >> c:\windows\temp\%computername%.log
if exists file2.exe >> c:\windows\temp\%computername%.log
Will the script achieves want i need?
Best regards,
JLuz
If you just want to find the details of file, like its location, name, size, version etc... then enable Software Inventory Agent which can fetch all details for you.
Delete