PowerShell Logging – The Basics

PowerShell Logging will be the best thing you learn.  The biggest topic I get asked for help outside the specific activities I am assigned to is PowerShell.    I will be the first to understand everyone has their own style.  I never judge the style or syntax format.  Besides that, PowerShell logging ALWAYS needs to occur.  If you are not logging, your running blind. PowerShell logging is the one the most powerful features you can learn and implement.  

PowerShell does have some native abilities, “Start-Transcript“, and if that is all you want to understand, that is fine.   But, this post will take you through some basic understandings on capturing your outputs in a format that is readable and standard.  With some tricks in creating some great logic around managing your log.

PowerShell Logging – The Setup

The first step into your new logging endeavors is to understand the ability to call a function to simplify your process. 

For this function to become usable we first must set the variable “$logpath” so the function can understand where it is writing to.   My standard is to log to “%SystemDrive%\Windows\Temp”

Calling the Function

During your process of creating your script you will want to call the PowerShell logging function to say your going to run a process, log the process file call, its arguments, other module calls, and most important capturing any error output. 

PowerShell Logging – Catching the Exception

When starting any process, module, function, or block you should wrap it in “try and catch”.  This will ensure you script never exits unexpectedly and you always capture what is happening.  This is what I have found to be the easiest way to handle most scenarios. 

PowerShell Logging – Using the Error Variable

A option for logging functions is with the built in “cmdlet” switch “-ErrorVariable”.  This parameter captures the error of the function you are running.  To test use the following example. 

PowerShell Logging – Capturing the Exit Code

When you run “Start-Process” you can capture the exit code when you assign it to a variable with the “-wait” switch included.   This helps when you need to capture non-failure exit codes. For example the “3010” exit  code means there is a “Soft Reboot” required.  This exit code is not a failure.  

Bringing It All Together

The below script block brings the above examples together.  Calling the process through a try and catch loop and checking the exit code. 

PowerShell Logging – SCCM Task Sequence

If your responsibilities have you running a lot of processes in a SCCM task sequence environment the following code block will be most helpful.  This will allow you to log to the same directory the SCCM task environment is logging to. The below script block outlines loading the COM object to test if you are in such an environment and gather the directory where logging is occurring. 

When the Microsoft Deployment Toolkit (MDT) is integrated, and utilizing the “Copy Logs on Error” function, these logs will be copied to the log monitoring directory.  

PowerShell Logging with a Process

When developing a process that runs on a schedule you will want to manage the file.  The below script block shows how to parameter the log location and size of the file; with applying a header to a new log file.

PowerShell Logging to the Event Viewer

When developing workflows, services, or schedule tasks you can use the system’s event viewer to capture your necessary output.  Utilizing the system’s Event Viewer with PowerShell Logging will allow you to monitor the process with a tool like System Center Operations Manager, Microsoft Operations Manager Suite, or any other log analytic system. 

With All That Being Said

When developing your next PowerShell script or process; I hope this post has outlined some necessary tools or ideas that will ultimately lead to more PowerShell logging.  Just having this in tool box has saved me countless of hours sifting through command windows and debugging the script.  

Configuration Manager (SCCM) Power BI Reporting

I would like to introduce you to the next generation of endpoint reporting we created at Ascent Solutions.  System Center Configuration Manager (SCCM) vNext Reporting with Microsoft Power BI. Microsoft Power BI is the insight engine that your organization needs.  Not with just Configuration Manager reporting, but extending out into your cloud, data center, ITSM, ITAM, and even your security vulnerability scanning appliance. 

Does your organization have a grip on client reporting health, let alone if your getting the latest Windows updates deployed.  These are tough questions to ask new customer’s when we need to properly plan a new roll out.  

This video takes you through some developed possibilities.  These solutions are in constant development. I am adding new insights weekly to these reports. Microsoft’s Power BI give us no limits into your organizational IT makeup, including but, not even close, limited to, Microsoft Operations Management Suite, Azure SQL, Amazon RedShift, Oracle, and MySQL, and etc….

Continue reading

Removing Windows 10 Universal Apps

Today’s Windows 10 Deployment Tip will include one of the most demanded help for Windows 10. We will go over how to remove Windows 10 Universal Apps for your production Windows 10 build.

The biggest misconception is that you remove Windows 10 Universal Apps during your build and capture.  These Apps will need to be removed during your Production OSD Build.  This can be easily done by incorporating a Run Command Line / Run PowerShell Script task sequence step that runs the below code / script.

Continue reading

Windows 10 Deployment Tip – 2016-08-08

With the first Windows 10 Deployment Tip of this series, we will cover the most basic situation.  Building your reference image.  Yes, you have made the investment in Configuration Manager, but the best way to build your Gold image is still with the Microsoft Deployment Toolkit (MDT).

Even if you use MDT in your environment today.  It is recommended to setup a dedicated Deployment Share just for your build and capture.

Continue reading

SCCM / ConfigMgr Driver Package Best Practice


This post will outline driver package creation, management, and best practices for System Center Configuration Manager (SCCM / ConfigMgr). The steps outlined in this post will ensure minimal driver management in SCCM, while ensuring the end device receives the proper drivers during imaging.

Staging and Imaging the New Device

The first step in the process is to get the new device able to image with the environment’s gold image.   You will have to note that it may be necessary to inject the network drivers into your Windows Pre-Installation Environment (WinPE) boot image. If the device fails to load the WinPE environment it is either the network or storage drivers are not available.

Pick the below scenario that matches your environment:

  • The Task Sequence deployed to unknown computers and the local administrator password is set
    • Begin imaging the device
  • The Task Sequence deployed to unknown computer but the local administrator password is not enabled
    • Copy the task sequence to enable the local administrator account, deploy the task sequence and start imaging the device
  • No task sequence is deployed to unknown computers but the local administrator password is set
    • Import the device and add it to the proper collection and begin imaging
  • No task sequence is deployed to unknown computers but the local administrator password is not enabled
    • Copy the task sequence, enable the local administrator account, deploy the task sequence, import the device, and begin imaging the device

To import a device into SCCM follow the steps outlined in the below link:

If network drivers are in the Operating System media that task sequence will complete successfully.  If the device does not receive a network driver it will fail, and you must logon as the local administrator.

Continue reading

Windows 10 1511 BUG – DISM File Associations

Just wanted to share some Windows 10 deployment notes from the field.  My colleague Ryan Fitzgerald and myself have been troubleshooting file associations not being set properly in Windows 10 build 1511.  This has been confirmed from Microsoft Premier Support, that there is a current bug in 1511 that causes DISM not to properly set file associations.

I have tested this on insider build 14271 and file associations are still broken.  Insider build 14279 is being downloaded now.  I will strip DISM from there, and run DISM 14279 on the 1511 / 10586 upgrade sequence to see if will set the file associations as desired.

Stay tuned….

Ascent Solutions – A New Chapter

I am on my seventh day at Ascent Solutions.  I have accepted a position as a Cloud Architect, with the mind on helping customers bridge the gap on managing devices through the Cloud.  I am please to be part of this elite staff, and look forward to challenges of growing our business in the endpoint management field.

I will have always have a place in my heart for Pomeroy.  It was great learning experience working for a IT Outsourcer, and see what it goes into transitioning a customer.   I will rely on those learning experiences, and without Pomeroy I wouldn’t be the person I am today.

Thanks again Pomeroy.

And rebirthing the way customers think of their IT Operations is still my goal.  Thanks for reading.


Windows Migration Utility

Since Microsoft has decided to implement a true OS migration in Windows 10, I have decided to release my tool for the IT masses. The Windows Migration Utility is a User State Migration Tool (USMT) GUI.

The Windows Migration Utility is built for migrating user and system data to a user defined location. Configuration of what is captured and restored uses USMT’s methodology of specifying configuration rules in XML files.  Windows Migration Utility utilizes the latest USMT version 5.0, so there is no reason for worrying about mapped network drives and printers USMT 5.0 does it.

Continue reading

PowerShell Uninstall Automation

I have authored the PowerShell Uninstall script.  It gives the ability for IT Operations / ConfigMgr Admins to uninstall multiple versions of a particular software with one process.

Does your organization struggle when trying to cleanup software when standardizing on a application version? I.E. Oracle Java, Adobe Flash, RightFax, IBM products, etc…  Not all the versions you have are in ConfigMgr / SCCM or not in the application model?  If the answer is yes, the PowerShell Uninstall script is for you.

The PowerShell Uninstall script takes inputs from a CSV file.  Using the delimiter of “^”, don’t worry I have included a Excel file to build your CSV.

Since by nature when uninstalling legacy software there maybe pre-or post- process you must run. The PowerShell Uninstall script has functions to call a PowerShell script before or after the uninstall logic.

The PowerShell Uninstall script also includes a Boolean to  create the script as an ConfigMgr / SCCM Application.  In which you can attach to other programs for requirements.

To detect the PowerShell Uninstall script, have ConfigMgr / SCCM check existence of “%SystemDrive%\Program Files\Pomeroy\AppName”.  It will be an empty directory.  For the uninstall just use the command “rmdir /Q /S %SystemDrive%\Program Files\Pomeroy\AppName”

Continue reading

Windows 10 Enterprise Thoughts

This past Wednesday, January 21st I was able to watch the Windows 10 Media Briefing.  This was a great presentation.  It gave a glimpse at what truly Microsoft is trying to create.  It seems like Microsoft followed its true self.  Failing and succeeding every other major release.  But true to their fashion they seemed to have out done themselves on this one.

Microsoft’s vision has always been unification.  As software always out performs hardware it truly wasn’t possible when they started this journey over a decade ago.  I have been using Windows 10 Enterprise build 9879 for my home lab admin workstation.  I technically haven’t truly used it to its full ability, but it has been good with the System Center consoles.

Enough of my jabbering, lets get to what I think are the key points on a enterprise management take.

Windows 10 Device Support

Windows as a Service and FREE Windows 10 Upgrade

This is a interesting aspect on they way Microsoft is approaching this.   Microsoft is implementing Software Assurance for everyone.  I believe they are saying Windows 10 is the foundation of whatever they build or release in the future.  It is a great way in getting people to upgrade.

This is more than a one-time upgrade: once a Windows device is upgraded to Windows 10, we will continue to keep it current for the supported lifetime of the device – at no cost. With Windows 10, the experience will evolve and get even better over time. We’ll deliver new features when they’re ready, not waiting for the next major release. We think of Windows as a Service – in fact, one could reasonably think of Windows in the next couple of years as one of the largest Internet services on the planet.

Cortana Everywhere

Cortana is coming to all your Windows devices.  This is a great leap forward in creating a personal experience with your device.  In which we all know we can’t live with out.  I look forward in what Microsoft will do with Cortana.

Cortana learns your preferences to provide relevant recommendations, fast access to information, and important reminders. Interaction is natural and easy via talking or typing, with advanced features to control Cortana for more trustworthiness and transparency.

Cortana Everywhere

The Same OS for Your Desktop, Laptop, Tablet, and Phone

While phones will not run native Win32 applications it will still run your modern apps.

Windows 10 for phones and small tablets features a fast, fluid and familiar experience that seamlessly interacts with your PC.

Windows 10 For All Devices

Continuum Mode

I think this is what makes Windows 10’s possibilities so great.  The intuitive approach for balancing touch enabled and traditional point and click devices.  I am not going to say this will get rid of iPads in the enterprise, but when you are talking Surface Pro 3 as laptop and tablet killer.  Right now iPads are used for executives who want mobility.  Well if you give them a Surface Pro 3 instead of a laptop and iPad, this bring more simplicity and standardization to your environment.

On 2in1 devices, Windows 10 will move easily between keyboard/mouse and touch/tablet as it detects the transition and conveniently switches to the new mode.


Project “Spartan”

A intuitive browser for the web enabled world.  This offering of a beefed up “Reading Lists” application.  In what I do I don’t usually screen capture websites and draw on them.  But saying that I do understand there is a whole industry of web development and business that would love this.

Code-named “Project Spartan,” the next generation browser was built with greater interoperability, reliability and discoverability, with a new look and feel built just for Windows 10. Advanced features include the ability to annotate by keyboard or pen directly on the webpage and easily share with friends, a reading view that is distraction free, displaying the article in a simplified layout for a great reading experience for Web articles online and offline, and the integration of Cortana for finding and doing things online faster.


Office Universal Apps on Windows 10

Being in the IT Operations industry, Office is 90% of the time a core application for a company.  Microsoft finally did, with backlash from the Windows Phone and tablet community, released a touch centric version for the iPad and Android.  This brings a touch-centric and rich document designing experience.  I cannot wait to try this out.

Office universal apps on Windows 10 offer a consistent, touch-first experience across phone, tablet and PC with new versions of Word, Excel, PowerPoint, OneNote and Outlook. Designed from the ground up to run on Windows, you can easily create and edit Word documents, annotate slides in real-time with new inking features or easily present PowerPoint presentations, and with new touch-first controls in Excel you can create or update spreadsheets without a keyboard or mouse. The next version of the Office desktop suite is also currently in development, more on this in the coming months.

Office Universal

Bonus: Microsoft’s Surface Hub

I am not going to speculate on this right now as Microsoft didn’t release a price for this yet.  But its a 84″ computer focused on meetings and presentation.  As you will see if you watch the briefing.

From no screen to 84”, with Microsoft Surface Hub we introduced a new large screen device designed for the way teams in the workplace naturally interact and come together.  Custom versions of Skype for Business and OneNote are integrated into the Windows 10 shell to take full advantage of the built in cameras, sensors and mics, as well as the new screen that was built from the ground up for ink and touch. The Surface Hub features state of the art digital white boarding, instant remote conferencing, the ability for multiple people to share and edit content on the screen from any device, and a trusted platform for large-screen apps. Available in two sizes – 55” and 84” – the Surface Hub removes the current limitations of traditional conference room scenarios to empower teams to create their best work together.

Microsoft's Surface Hub

Closing Thoughts

I think this is the most excited I have been for a Microsoft release; including the Xbox 360.  I think the blend and unification will actually happen with this release.  Especially the way Microsoft has planned this release.

Read the Windows’s blog here: http://blogs.windows.com/bloggingwindows/2015/01/21/the-next-generation-of-windows-windows-10/