Posts

How to use a PowerShell try catch statement

Image
In PowerShell, error handling is crucial for creating robust and error-resistant scripts. One of the most effective error-handling techniques is using try-catch statements. In this blog post, we'll explore the basics of try-catch statements and how to use them in real-world scenarios. What is a Try-Catch Statement? In PowerShell, a try-catch statement is an error-handling mechanism that allows you to execute a block of code (the "try" block) and, in case an error occurs, execute another block of code (the "catch" block) to handle the error. This way, you can control the script's flow and respond to errors accordingly. Basic Syntax: try { # Code that might throw an error } catch { # Code to handle the error } Example 1: Reading a File In this example, we'll try to read the content of a file. If the file does not exist, an error will be thrown, and we'll catch it to display a custom error message. try { $content = Get-Content -Pat...

How to setup and configure CMG in SCCM

Image
 Microsoft System Center Configuration Manager (SCCM), also known as Endpoint Configuration Manager, is a comprehensive solution that helps organizations manage their devices and applications. With the Cloud Management Gateway (CMG), you can extend the capabilities of SCCM to manage your devices over the internet. This blog post will guide you through setting up and configuring the Cloud Management Gateway for SCCM. Prerequisites Before diving into the setup process, ensure that you have the following in place: A Microsoft Azure subscription. An SCCM hierarchy with at least one primary site. The SCCM version should be 1806 or later. A PKI infrastructure for HTTPS communication (optional, but recommended). Step-by-Step Guide to Setting up and Configuring Cloud Management Gateway for SCCM Step 1: Create a Cloud Management Gateway in the Azure Portal Sign in to the Azure portal (https://portal.azure.com). Click on "Create a resource" and search for "Cloud Management Gateway...

How to enable Windows Server Data Deduplication

Image
SCCM can take a lot of space having to store drivers, wim images and various software. A great way to reduce the amount of space that those items are taking up and stretch your disk space to last longer is to enable Windows Server's built-in file deduplication. Starting in Windows Server 2012 Microsoft released a feature called data deduplication . The built-in data deduplication works on the bit level so files don't need to be exactly the same for the deduplication to work, they only need to be alike down to the bit.  Step 1: Check for File Deduplication Support Before you start, make sure your Windows Server supports file deduplication. This feature is only available on Windows Server 2012 and newer versions. Step 2: Install File Server Role If you haven't already, you'll need to install the File Server role on your Windows Server. This can be done using the Server Manager. Step 3: Install Data Deduplication Feature Next, you need to install the Data Deduplication fea...

PowerCopy 4.0.0

Image
 Just recently I released the newest version of PowerCopy. This is the first complete redo of the application fixing various bugs, adding new features,s and optimizing the application.  Changes  Fixed an issue that wouldn't allow for multiple exclusions  Fixed a bug that would stop all instances of robocopy when you click the stop button in PowerCopy  Added a feature to change how PowerCopy will over wite files and folders that are already present in the destination  Added a progress bar for the overall progress of the job and a progress bar that shows the status of the current object that is being copied  Added an option to use backup mode so files in use can be copied  Simplified the output box to show what is being copied  PowerCopy can be downloaded from the main PowerCopy Page  

SCCM Applications vs. SCCM Packages: Understanding the Key Differences

Microsoft System Center Configuration Manager (SCCM) is a versatile and powerful tool for managing devices, applications, and updates in an organization's IT environment. Among its many features, SCCM allows you to deploy software to your end-users in two primary ways: Applications and Packages. Although both methods have a similar goal, they have some key differences that IT administrators should understand when choosing the appropriate deployment method. In this blog post, we will explore these differences and help you decide which option is best for your organization. Definition and Deployment Scenarios SCCM Applications: An SCCM Application is a high-level, user-centric deployment method that focuses on providing the desired user experience. Applications are designed to be state-based, meaning they can detect if the application is already installed and only perform the necessary actions if the application is not present or if a newer version is available. Applications are suita...

7-Zip App Vulnerability CVE-2022-29072

Image
  In the last day or so CVE-2022-29072  was released. This is a vulnerability that allows an attacker to use a malformed 7zip archive to gain local administrator rights to a computer. Until an official patch is released one of the recommended ways to resolve this is to remove the 7-zip.chm file as it is the Windows help system. We have put together a script to do just that.   $Vols = Get-Volume | Where-Object -Property DriveType -NE "CD-ROM" | Where-Object -Property DriveLetter -ne $null foreach ( $V in $Vols ) { $Files = ( Get-ChildItem -Path $( $V.DriveLetter + ":\" ) -Recurse -Filter "7-zip.chm" ).FullName foreach ( $F in $Files ) { Remove-Item $F -Force } } You can plug this script into an SCCM package to deploy to all your systems. Since 7zip offers a portable version and some software uses 7zip as a built-in utility we made the script scan all volumes on the computer that are not CD-ROM drives and that have a...

Latest Software Deployment Scripts

Image
One common issue we face as SCCM Admins is trying to keep common software up to date. Things like Chrome, Firefox, and VSCode always have new updates and maintaining that across Application deployments and Task Sequences can be tricky. I have started to use some script wrappers to help with this. These scripts are able to be packaged up as an application and deployed however you need it to be used.  I have created 2 scripts for each application, First is the app.ps1 and the second is install.cmd. The app.ps1 script is what does all the heavy lifting, the script will download the latest version and install it as well as find the needed string to run an uninstall command so an uninstall action can be provided in Software Center. The install.cmd script is a simple batch script that executes the ps1 script. I have included this to make it easy to create an application for the script as well as provide a simple way for a technician to run the scripts independently of Software Center or ...