Use CM Console scripts node to gather log files from CM Clients
To assist in answering a question in this forum post:
I'm blogging on behalf of Srikant Yadav; he gave me permission to do so. Thanks Srikant!
How to make this work..
Make a location on a server you manage/control--which has lots of space.
create a folder called (for example):
Share that out as ClientLogs$
At a minimum, you need these permissions (if you have multiple domains, or support non-domain joined computers, you'll have to figure out what other permissions might be necessary).
For share permissions, because who will be 'copying' the logs to that share is a computer, add the group:
<your domain where your computers live>\Domain Computers, with Change, Read.
On that folder of E:\ClientLogs, for NTFS permissions, add Modify, Read & Execute, List folder contents, read, Write (aka, everything but full control) to
<that same group you just did for share permissions, aka, \Domain Computers
In the --> attached <-- is a script. Modify the parameter within that script which is currently...
$Destination = "\\<DummyShare>\ClientLogs$"
To be \\YourServer\ClientLogs$
Save that modified script as <some location you'll remember>\ImportThisIntoCM.ps1
In your CM Console, go to software library, scripts, create script
ScriptName = Retrieve Client Logs
Script Language = Powershell
Import... and go to <some location you just said you'd never forget> and import that ImportThisIntoCM.ps1 script.
Review the Script Parameters. You can, if you wish, modify the defaults of the parameters here. For example, maybe you ALWAYS want to get any ccmsetuplogs, or you know you only want log files that will be within the last 5 days and nothing older.
double-check the Destination is the right servername and sharename
Next, Next, Close.
Approve the script in the Scripts Node. You may need a peer to do the approval. In smaller environments, if you are the only admin, you can self approve scripts in the Scripts node if you've configured that in Site Configuration, Site, Hierarchy Settings, uncheck "do not allow script authors to approve their own scripts". This is a safety feature, that you SHOULD leave checked--because scripts can be powerful. Some disgruntled admin COULD make a "format c:" type of script, self approve it, and send it as they walk out the door. Just saying... you might not want to do this. peer review of scripts is GOOD.
As an example, in Assets and Compliance, Devices, pick on a Online device (obviously this only works if the target is online/available), right-click, Run Script. Pick "Retrieve Client Logs". At this point, you can change parameters as needed. Next/next. You'll see a progress bar.
When it's done, in the \\yourserver\ClientLogs$ will be Subfolders; CMClientLogs$ for cmclientlogs, WindowsUpdateLogs$ for WindowsUpdateLogs, etc. Inside those subfolders will be the zipped-up log files, named for the device name targeted.
Have a Cleanup Routine. The \\YourServer\ClientLogs$ doesn't have any automatic cleanup routine around it. If say... you were to gather log files all the time, wherever that location exists might fill up the drive. You want to remember to clear that out either manually occasionally, or setup some kind of maintenance routine on that server to "delete xx when older than yy days" or something.
Possible updates...If you read through the script, you'll see that you can make this extensible yourself. Perhaps you have a <App Specific to our type of business> which has log files that are always stored in c:\programdata\Widgets\Logs. You can easily add a new section to the script, with another parameter to grab those log files as needed, if needed.
- Created on .