OSD Driver installation via PowerShell

Today we are going to install the model-specific driver packages using PowerShell script. The advantage of using this method of driver installation during the Operating System deployment is to reduce the overall Task Sequence deployment time, This method is more suitable if you have multiple hardware devices with multiple vendors (Dell, HP, Lenovo, Microsoft, etc...) 

In order to achieve this method follow the below steps. 

1. Create the folder structure as below.
        a. Vendor\Hardware model\

2. Download the specific hardware model driver package from the vendor website and extract the cab files.

3. Archive/Zip all the extracted drivers into one single folder called "Drivers.zip".

4. Copy DISM folder from ADK installed machine and place into the "Vendor\Hardware model\"
path of DISM-(C:\Program Files (x86)\Windows Kits\<version>\Assessment and Deployment Kit\Deployment Tools\10\DISM)

SCCM SQL query to get the full OS version with build number

 Today, again we are going to create one SQL query..... 

Today we are going to pull the Operating System version with the build number. from SCCM SQL database.

For a single machine, you can run the command "Winver" from the run and you will get the below information

Operating System build version

SCCM SQL query to get machines with user id, name, email, last logon

Hello Friends, Good evening and how are you?

Today someone asked me to create one SQL query to get the machine details like hostname, IP Address, RAM, total HDD size, Free Space, Manufacturer, Model, Last Heartbeat, Users name, email ID, Last logged on user name.

Also, We will fetch the domain details and CCM client active status.

SCCM SQL Query, Machine details with User name and email ID, SQL Queries, SCCM  SQL master query, ConfigMgr SQL query, ConfigMgr, SCCM SQL reports




















Distribute multiple packages on multiple distribution points

Hello Guys, Hope you are doing well. Today we are going to automate the package distribution.

This script will help you to distribute multiple packages on multiple distribution points.

let's download the PowerShell code mentioned below and run it from any SMS Provider server.


Distribute Multiple packages on multiple distribution points


Error during connection to SMS_DP$(67)

Today we were facing some issues with our Distribution Point server. Wintel has confirmed the issue with the Operating System and has wiped and loaded the C Drive and D Drive was remain the same.

Now, the actual problem has started while updating contents on the DP. We are getting below errors in random.

"There is no existing connection. win32 error = 67"
"Error during connection to SMS_DP$(67)"
"Attempting to connect failed"












Resolution:

SCCM image migration to new server

 Hello Guys, hope you doing well and are using the automation scripts, and are happy with the way of automation.

Today we are going to discuss some troubleshooting parts.

If you are going to migrate your existing SCCM infra to the new hardware, from the Build site you need to migrate your Driver packages, Boot Images, Task Sequences, all TS dependant packages, and off-course Operating Systems to the new SCCM server.  

obviously, you have to create a migration job to do so. The migration job wizard will help you to migrate the objects from one SCCM server to another. While migrating the WIM files from existing SCCM infra you might be getting the below error.






OSD log file locations

While deploying the TS on the targeted machine we are experiencing Task Sequence failure on various steps. like before format the Hard Disk, after format the Hard Disk or post-Win-PE stage.

Below are the scenarios from where you can gather the required log file for further troubleshooting.

OSD log file locations:

Phase -Windows PE (Before the hard disk are formatted)

Location - "x:\windows\temp\smstslog\smsts.log"

Phase -Windows PE (After the hard disk are formatted)

Location - "x:\smstslog\smsts.log" and copied to "c:\_SMSTaskSequence\Logs\Smstslog\smsts.log"

Phase -Windows Operating System (Before the SCCM client is installed)

Location - "c:\_SMSTaskSequence\Logs\Smstslog\smsts.log"

Ping multiple hostnames in single PowerShell script.

Guys, In a day-to-day activity, we have to perform repetitive tasks like check the availability of the server by using ping utility and send the report to management. while doing this activity manually, this is an irritative task, while using automation, it's pretty easy.

Let's create a new PowerShell script and insert the below code. once you save the ps1 file.

create another file with extension .txt and put destination servers which do you want to ping and save that text file with the name "inputcomputers.txt" at the location where you save the ps1 file.

You can run the PowerShell with Task Scheduler or Simply run PS1 to get the ping report in "outputcomputers.log" 😀👍

Add domain user in Local Administrator Group

Today we are going to create a simple script that will help us to add domain users, into the local administrator's group via batch script.
Create a new notepad file and insert the below code into it. Once done save the notepad file with .bat or .cmd extension and place this file on the shared location and execute with psexec or PowerShell PSSession

Finally, your script will be looks like as shown in the above image✌

While running the script remotely we have to remove pause from the script and then execute the script.

TaskBand customization during TS execution PowerShell Solution

Friends, Hope you are doing well. Today we are going to automate the taskband during the imaging process. We will create the taskband package using Powershell and deploy the package via a task sequence. alternatively, you can use the batch file instead of PowerShell.

What first?

First, we have to log in on the reference machine from where we are capturing the taskband files and settings.

Pin the taskbar items whatever you want😊 as per your org requirement, not blindly😏




go to location "%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\"

TaskBar Customization during Task Sequence execution Batch Script

There are two ways to customize your TaskBand during the Task Sequence execution.

1. Using PowerShell script

2. Batch Script as described here.

Pin the taskbar items whatever you want😊 as per your org requirement, not blindly😏

go to the location "%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\" 

copy all the shortcut files from this location and save them to your reference package folder.

for me, I have created one folder on the reference machine desktop named "TaskBandAutomation\Taskbar".

now what next? open registry settings for users and navigate to "Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" and say export and save as TaskBand.reg. where? on your desktop or anywhere you want. anyway, we have to delete this file after getting some info from it.

Make CMTrace as default log viewer during the Imaging process(OSD)

While analyzing the SCCM logs every engineer wants to open log files by default in CMTrace. But When you log in to a new build machine and open the CCM logs or any *.log files from the machine, the log files will open in the notepad by default. Reading the SCCM log files into notepad is very difficult, Microsoft is providing the live log reading tool call CMTrace with the SCCM suite. In this post, we are going to make it the default app for log files. We will create the SCCM package and deploy it via Task Sequence execution while Operating System Deployment step.

To achieve this, create a new package using the below PS1 code and deploy it on required DPs

Cleanup Image before Capture - Event Viewer cleanup batch file

Guys, Why WIM Image cleanup is more important ? This is because it delivers error-free images to the customer and reduces the manufacturer's bugs and issues. While troubleshooting the end-user machine, there should not be previous logs that can create confusion.

If you are going to clean up the event viewer logs one by one manually it will take your whole day and also an irritating job for you. don't worry we have created a simple and easy script that helps you to clean the event viewer logs within a minute.

clean reference images before capturing them in WIM format.


Auto Diskpart and stale entry delete from SCCM during Imaging process

I know many of the build administrators are deploying the Task Sequence on unknown device collection. I purpose and the idea behind it is to do not deploy the task sequence on a production device and prevent accidental data loss.

If the machine is in SCCM collection and we want to run the task sequence on it, we must SCCM Console and do a manual deletion job and wait for a couple of minutes to restart the imaging on the target machine

This is a time-consuming and repetitive task for us. Can we create a way to do this in an automotive way? Like, create the PowerShell Script, which will automatically read the machine's MAC Address and connect to the SCCM database from the WinPE environment for getting all the hostnames to hold by that mac address and delete each.

Also, can we do a diskpart at the same time to avoid further imaging failure? Yes we can create the PowerShell Script and integrate it with Boot Image, which will automatically check whether the machine having an internal storage device attached or not, and based on the results script will perform Diskpart operation, if the internal storage device is faulty or not connected in BIOS, the script will prompt the error.

Provide Hostname and delete Machines from SCCM console - PowerShell automation

Hello Friends,

Suppose, if I have 200 machines hostname and each hostname having 2-3 machines in the SCCM console and you want to delete each machine from the console. you will be irritated doing this job manually. the reason behind it, its time-consuming activity and repetitive task.

why you are not doing smart work? how?

Let's say we have a scenario like above and you have one PowerShell script in which you added all the machines hostname into it and just run the script and it deleted all the desired machines from the console while you finish a cup of tea 😉

Yes, We can create the PowerShell script like this using ConfigurationManager.psd1 SCCM PS module.

Import the PowerShell module first and then connect to the Primary Site Server. To get the hostname of the machine from a file, we have to create one input file named "hostnameinput.txt" in the same directory where we have created and kept the PowerShell script. Once you create the input text file paste all the machines hostname into the file and runs the below script with SCCM admin privileges.

Provide MAC address and delete Machines from SCCM console

Hello Friends,

If I have 200 machines MAC Addresses and each MAC address having 2-3 machines in the SCCM console and you want to delete each machine from the console. you will be irritated doing this job manually. the reason behind it, its time-consuming activity and repetitive task.

why you are not doing smart work? how?

Let's say we have a scenario like above and you have one PowerShell script in which you added all the MAC addresses into it and just run the script and it deleted all the desired machines from the console while you finish a cup of tea 😉

Yes, We can create the PowerShell script like this using ConfigurationManager.psd1 SCCM PS module.

Import the PowerShell module first and then connect to the Primary Site Server. To get the MAC Addresses from a file, we have to create one input file named "macaddressinpput.txt" in the script root directory where we have created and kept the PowerShell script. Once you create the input text file paste all the MAC Addresses into the file and runs the below script with SCCM admin privileges.

Connect SCCM console via PowerShell

PowerShell is a more powerful tool to manage the System Center Configuration Manager.

To connect the SCCM using PowerShell, you can use the below PowerShell script.

When you execute any cmdlets or script by using the PowerShell console, your cmdlets or script will be runs in the primary site server.

Add the below line into the PS Script when you are importing the SCCM module first time on the machine.

Uninstall application from computer powershell - If computer name ends with latter D

Sometime before I have received one crazy request from the team, They want to uninstall 2 plugin apps from the production machine. but the condition is if the machine name ends with letter "D" then only start uninstallation from the machine, else leave the applications as it is.

In the PowerShell script first, we have to determine the computer name and then check if the machine name is ending with the letter D and finally we have to start the uninstallation from the target machine.

so here are 3 requirement block has to write in the script.

in the Uninstallation program name, we have used the uninstallation string from registry - Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\

if the application is x64 bit version then we have to collect the uninstallation string from the registry path -Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall.

Image Validation Script used in TS execution, OSD validation

Hello Friends,

As a build administrator, post Operating system deployment, Image Validation is a very very important task. There are multiple parameters we have to check post OS installation.
Like, we have to check each and every application installed on the machine and also check the version of each application, whether it's installed correctly or not?

We have to check whatever the patches we have targeted to the device are installed properly or not?

Sometimes we are getting requirements from clients saying that we have to set some services in disabled mode and some services we need to set as an automatic start. These services' startup type and status should be the same as we configured before executing Task Sequence or while capturing the WIM file.

Manual drivers validation is again a very difficult task, why not capture all the drivers installed on the machine and save it in the same CSV file for further validation.

remove domain user from local administrators group

Today we are going to create a simple script that will help us to remove domain users from the local administrator's group via batch script.
Create a new notepad file and insert the below code into it.

Once done save the notepad file with .bat or .cmd extension and place this file on the shared location and execute with psexec or PowerShell PSSession.

While running the script remotely we have to remove pause from the script and then execute the script.

Finally, your script will be looks like as below ✌

AD Authentication PowerShell script.

 Hello friends, In some scenarios tech guys have to provide their username and password to join the machine into the domain. and Task Sequence wants to store the info somewhere before execute the actual domain join step.

I have seen the problem, that sometimes builds engineers are not providing the correct username and password to the TS and the domain join step is getting failed due to incorrect username and password.

Don't worry! this is a common issue with anyone and we can fix it by checking the user is present on AD and will authenticate him at the same time when he provides the credential details to the Task Sequence.

How?

Domain join is failed due to network unavailability during TS execution

Hello friends,

Domain join is the most important step in the Task Sequence. If the domain join does not happen, there is no value to execute the task sequence ahead. Because if we missed joining the domain during the task sequence execution, the domain users can not log in to the machine and we have to reimage the machine again, simply this waste of time.

Here is one important thing we have to note down, this step is not failing anyhow. So, if the domain join is failed even. Still, a task sequence will execute the next step.

We only know that domain join is failed while login in the machine post-task sequence completes.

Why is domain join fail sometimes?

We are joining the machines to the domain once driver installation is done (before first reboot the machine). We observed post drivers’ installation sometimes network drivers loos the connectivity and this is causing the domain join failure.

User base Drivers installation - Max Audio Pro For Dell

User base drivers?

yes, We have some drivers which need to be installed in the users' contexts.

This post is not about the driver's installation but moreover about installing any package which is purely created for the user. 

The below script will install the user base "Max Audio Pro For Dell" drives post Task Sequence execution and on first-time users login into the machine.

We have to place the whole setup file along with the below script on the target machine for user base installation post Task Sequence.

The trigger.bat we have to create with the script code:

MKDIR "C:\ProgramData\OSD_MaxAudio"

xcopy.exe ".\*.*" "C:\ProgramData\OSD_MaxAudio" /D /E /C /I /Q /H /R /Y /S

Services management during OSD Task Execution

Hello Friends, During the OSD Task Sequence execution process, We have to disable and stop some services, or sometimes we have to enable and start the services from Windows services.msc console.

We can use cmdlet from PowerShell "set-service" to manage the services on the windows operating system.

To manage the bunch of services during Task Sequence execution, We have created the below PowerShell script and managed some of the services. you can change the service name and startup type as per your requirement.

also, you can use this PowerShell script before capture the WIM file or it can be used during the TS execution time. in both scenarios, we can manage the services.

Services management during OSD Task Execution
Use the below script to manage the services during OSD.

Inject the Drivers during Task Sequence execution via Auto IT Script

Hello Friends, Here is another way to inject the drivers is based on the hardware mode. This time we are using the AutoIT script solution to create the script and us in the Task Sequence.

In order to achieve this method follow the below steps. 

1. Create the folder structure as below.

        a. Vendor\Hardware model\

2. Download the AutoIT script editor here and install it on your machine.

3. Write the below script in the "SciTE Script Editor" located  at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\AutoIt v3

Inject the Drivers during Task Sequence execution via Auto IT Script


4. Save the file as InjectDrivers.au3

Remove Windows10 bloatware from WIM using PowerShell

The logic behind writing this script is to remove unwanted built-in apps from Windows 10 1909 Operating System. This script can be used to remove Windows 10 built-In Apps in OS as well as in Task Sequence Deployment.

You can mention the list of applications to remove from the OS, based on your business requirement.

<#

    .SYNOPSIS

    Removing Windows 10 1909 Built-In Apps.

    .DESCRIPTION

   

    .NOTES

    =============================================================================================================================================

    Created with:     Windows PowerShell ISE

    Created on:       Wednesday, October 6, 2021 5:41:31 PM

    Created by:       Dashrath Chate

 

Create batch file to replace xml file restart app service and create detection rule

Hello friends, there are a lot of customized XML files we are using in the WIM and even during the Task Sequence execution. like startlayout.xml, defaultAppAssociation.xml, UDIWizard.xml.

Sometimes we are creating custom application installation through UDI Wizard using XML, some application settings need to overwrite using an XML file.

post OSD, technicians can’t copy-paste each and every XML file into the application install directory and there are chances of mistakes and can lead to a functionality break.

To overcome this issue, we can replace the application-related XML files safely during the Task sequence execution.

you have to customize your XML file and create a package along with one batch script inside it.

the batch file will act as a trigger while executing the action and use the %~dp0 functionality before the XML file name to replace the existing XML file from the package source directory. to overwrite the existing XML, we have to use the /y switch at the end of xcopy command.

Create local admin account with password during task sequence execution

What if the machine gets failed during the task sequence execution and not joined the domain too? How to login machine for further troubleshooting?? Is there any mechanism to create a local admin account??? (there are so many organizations not enabling the built-in administrator for security purposes)?

Yes, we can create the custom local administrator account and add them to the local administrators’ group. Also, we can set the password expiry - wmic useraccount where name='localadmin' set passwordexpires=false and password to the account - net user /add localadmin P@$$W)rd (you can choose a local admin username and password as per your requirement).

This script is more important because there is one default function also available in TS to use the built-in administrator or rename and use it. Then why we are putting extra effort and using this script?

The advantage is we are not creating the local administrator account if everything goes well, instead of, if domain join is failed then only, we are going to create custom local account to enable to local login functionality and help technician to gather the logs and take further action.

Cleanup unwanted files from the reference machine during Image Capture

Hello Friends, how are you doing today?

While capturing the WIM file, the Build Engineer has to clean the temp files created during the Image customization.

Also need to perform the System drive cleanup for defragmenting and windows update cleanup.

We have a simple solution to perform Image cleanup by executing the below batch script.

Cleanup unwanted files from the reference machine during Image Capture

Move all desktop shortcuts into one folder after complete the OSD

Hi folks, while working on projects we are getting so many Image customization requests and we have to fulfill those in a timed manner.

Here is one requirement requested by one of the customers to remove all the installed application shortcuts from the desktop and place them into one single folder on the desktop. The idea behind it freshly build machine's desktop should be clean and users should not bother with so many shortcuts.

While executing the applications from TS, machine base application shortcuts are getting created in the public user’s desktop and normal users cannot delete or move these shortcuts by themselves as they don’t have permissions to the public desktop directory.

Cool, we can move all the installed application shortcuts to a single folder in one click. How? using below script 😊

Xcopy during the Task Sequence execution achieve through batch file

Hey guys, We have to place wallpapers, screen savers, user profile pictures, machine base run scripts, userbase runonce scripts into the machine.

We cannot add these files and scripts into the WIM because it needs to change from time to time and should use the latest as per customer requirements. That’s why we always add these types of files into Task Sequence.

There is Xcopy command utility we can use in our script program to get this done.

While using the xcopy always use the %~dp0 and provide either each file name to copy to the destination or use wildcard *.*