Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

Copy and Zip OSD log files in a Task Sequence using Powershell

Posted on March 3, 2017March 17, 2021 by Jörgen Nilsson

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.

PSBootImage

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.

NAA1

Make sure the Account has been granted “Modify” permissions on your log share:

NNA2

Create a TS Variable “SLShare” and assign it the UNC-Path to your log share:

TS Step1

Create a Package (without program) or put the script in an existing scripts package, incorporate in TS as:

TS Step2

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:

Logfiles

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.

  • Configuration Manager
  • Powershell
  • Task Sequence
  • 5 thoughts on “Copy and Zip OSD log files in a Task Sequence using Powershell”

    1. Garrett says:
      May 2, 2019 at 2:10 pm

      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?

      Reply
    2. Richard says:
      October 16, 2019 at 6:27 am

      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?

      Reply
    3. Kris says:
      July 7, 2020 at 3:34 pm

      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

      Reply
      1. Jörgen Nilsson says:
        August 7, 2020 at 9:17 am

        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

        Reply
    4. ZiviZ says:
      March 3, 2023 at 9:27 pm

      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)”

      Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
    All code is provided "AS-IS" with no warranties.

    Tweets by ccmexec

    Recent Posts

    • Windows Servicing, Personal Teams and Success.cmd
    • Windows MDM Security Baseline – Settings Catalog
    • Configuring MS Edge Security Baseline v107 using Settings Catalog
    • Configuring Desktop App Installer using CSP and script?!
    • Customizing Taskbar and Start in Windows 11 22h2 with PowerShell

    ©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
    This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
    Privacy & Cookies Policy

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    SAVE & ACCEPT