My college Johan Schrewelius wrote a script to copy log files from OSD to a network share like the functionality we have in MDT so I thought I would post it here as it is brilliant. It can be downloaded here: Onevinn – Scripts (schrewelius.it)
The script “CopyOSDLogs.ps1” can be run anywhere in an OSD TS but is most often used in the Error Section, thus only run in case of a failed deployment. I wrote a post here a while ago as well on how to add some basic error handling in a standalone TS.
https://ccmexec.com/2016/12/error-handling-in-ts-without-mdt-using-osdbackground/
There are a couple of pre-requisites to make it work:
· We need to make sure that Powershell support is added to our Boot image.
· We need a location (file share) to save the logs.
· A TS Variable holding the UNC path to the share.
· The “First” Network Access Account must be granted “Modify” permissions on the share.
Make sure that Powershell is added to the boot image by adding it if it isn’t added already.
The script will use the Network Access Account for authentication; making it work also in the event of a failure during Windows PE, where we cannot use the computer account, as the machine is not yet domain joined
Check the name of your “first” NAA, if you have several it should be the one on top.
Make sure the Account has been granted “Modify” permissions on your log share:
Create a TS Variable “SLShare” and assign it the UNC-Path to your log share:
Create a Package (without program) or put the script in an existing scripts package, incorporate in TS as:
When the script runs, could be in event of a failure or if you want it to run always, the SMSTSLogs folder will now get zipped and stored as a single file on your log share:
If we combine it with the script also published on Technet Galleries to safely dump TS variables it will also be incorporated in the log files save, that script filters out all password and sensitive information so they are not part of the log file. Onevinn – Scripts (schrewelius.it)
That is great if we want to troubleshoot afterwards for instance which applications was installed dynamically using variables.
I hope you find it useful.
It is creating the folder on the network share, with 15 Files, and the Panther folder. But it also creates the ZIP with 13 files, and one LOCK file. No panther folder either. It also doesn’t delete the folder, it creates the folder and ZIP on the share. Am I missing something?
Hey, sorry to rejuvenate this blog post, I have been using this script for Bare Metal builds to migrate builds with success but is when using it for an in-place-upgrade, the log file zip is missing the hostname at the start of the zip file. e.g. -2019-10-11-16-43-32.zip. Is their any way it can be modified to use in that scenario? Also can it be used to collect other logs such as from
$WINDOWS.~BT\Sources\Panther and $WINDOWS.~BT\Sources\Rollback?
Hi, great post. One question for it is….what is in the eKlient package and is this needed to run this? Any links to creating the eKlient with the right content if needed? Thanks
Hi,
It is just a common package I use for scripts used, so simply create a new package and place the script in that source folder.
Regards,
Jörgen
Thank you for the script, it’s been helpful. I have a recommended change. I ran into an issue where my share path had spaces and this prevented the “net use” command from working leading to auth errors. To fix, I added quotes around the path on line 30:
$pinfo.Arguments = “USE `”$($UNCPath)`” /USER:$($User) $($PW)”