Few months ago i blogged about How to install SCCM client using win32 apps in Intune for co-management and CMG .when you create a win32 app for ConfigMgr client with the command line switches as said in the blog post, ccmsetup.exe will always get the source files from CMG.
The download of the client files from CMG happens due to the parameter /mp. This parameter will help client to download the content from the nearest distribution point. we want to avoid client to download client files from CMG and always use local source files (win32 app) that was downloaded from intune.
why do you need to use the local source files to install client instead of downloading from CMG? If you read the Microsoft article for CMG, Charges are based on data flowing out of Azure (egress or download). Any data flows into Azure are free (ingress or upload). So when client download source files of 240mb, there will be cost involved and if there are 5000+ clients download the data, this sums up to Terabytes and when you have already have source files locally available, why do you need to download from CMG again?
In this blog post, we will see how to install configuration manager client using IME cache data that is downloaded from intune without connecting to CMG.
Before we create win32app or make changes to command line switches, we first need to understand how to use offline source files.
Here is the powershell script that will do all the magic here.
we first copy the Configmgr client folder to c:\windows\temp\intunetemp and run the ccmsetup.exe with /source switch and other command line that will help client to assign to site.
we will try this until the ccmexec (SMS Agent host) service is installed (you can use other ways as well like registry etc.) to confirm configmgr client installed successfully.
If the ccmexec service installed then return code 0 else 1 after 5 retries with wait of every 60 sec.
Powershell:
<#
Name: Install SCCM Client 2303 using offline source files
Author: Eswar Koneti
For more information about command line switches https://eskonr.com/2020/05/how-to-prepare-sccm-cmg-client-installation-switches-for-internet-based-client/
Creation of win32 app https://eskonr.com/2019/12/using-intune-to-install-configmgr-client-as-win32-app-with-local-source-files-without-downloading-from-cmg/
#>
# Define the folder
$folderPath = "c:\windows\temp\intunetemp"
# Check if the folder exists, if not, create it
if (-Not (Test-Path -Path $folderPath -PathType Container)) {
New-Item -ItemType Directory -Path $folderPath -Force
}
Copy-Item -Path ".\Client" -Destination $folderPath -Recurse
c:\windows\temp\intunetemp\client\ccmsetup.exe /nocrlcheck /source:c:\windows\temp\intunetemp\client CCMHOSTNAME=SCCM.CLOUDAPP.NET/CCM_Proxy_MutualAuth/72057594037928694 SMSSiteCode=PS1
$retry = 0
while($retry -lt 5)
{
$service= get-service -name CcmExec
if($service)
{
exit 0
}
else
{
start-sleep -s 60
$retry ++
write-output "Retrying $retry"
}
}
exit 1
With this PowerShell script, we will now generate win32app in intune and assign it to the device group.
1. Create a folder called ConfigMgrclient (C:\ConfigMgrclient)
2.Copy the client files into ConfigMgrclient (C:\ConfigMgrclient\Client)
3. Save the above PowerShell script as install.ps1 into (C:\ConfigMgrclient). Don't forget to change the parameters in the ccmsetup.exe command line above.
4.Create an empty text file with name cmclient.txt (C:\ConfigMgrclient)
5.Download win32 app packaging tools from here
Now your folder content looks like this:
5.Open command prompt and go to win32 app packaging directory and run IntuneWinAppUtil.exe
6.Please specify the source folder:C:\ConfigMgrclient
7.Please specify the setup file:Install.ps1
8.Please specify the output folder:C:\ConfigMgrclient
To create win32 app, login to device management portal or azure portal and go to intune, client apps, add new app as win32
select app package file that we created above
install command: powershell.exe -exec bypass -file .\install.ps1
uninstall command: C:\windows\ccmsetup\ccmsetup.exe /uninstall
Requirements: you can choose as per your infra requirement.
Detection rule, registry key:
Key path:Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Mobile Client
Value Name:ProductVersion
save the app
Go to assignment and add device security group or autopilot AD sec group that you created to install client.
When you deploy the client to devices, ccmsetup.exe will download the files from C:\windows\temp\intunetemp folder.
with this, we managed to save cost for downloading the content from CMG and also the time that it takes for download .
Hope it helps!
8 Comments
I modified the script a bit after some failed attempts.
Try incorporating these changes (check for folder, check for ccmsetup and then ccmexec).
____________
If(-not(Test-Path "c:\windows\temp\intunetemp")){ md 'c:\windows\temp\intunetemp' }
Copy-Item -Path ".\Client" -Destination "c:\windows\temp\intunetemp" -Recurse
If(-not(Test-Path "C:\Windows\temp\intunetemp\Client\ccmsetup.exe")){ exit 10 }
c:\windows\temp\intunetemp\client\ccmsetup.exe /nocrlcheck /source:c:\windows\temp\intunetemp\client CCMHTTPSSTATE=31 CCMHOSTNAME=/CCM_Proxy_MutualAuth/72057594037928694 SMSSiteCode=
AADTENANTID= AADCLIENTAPPID= AADRESOURCEURI=https://
$retry = 0
while($retry -lt 2)
{
$service = get-service -name Ccmsetup
if($service)
{
$retry = 3
}
else
{
start-sleep -s 60
$retry ++
write-output "Retrying $retry"
}
}
$retry2 = 0
while($retry2 -lt 5)
{
$service = get-service -name CcmExec
if($service)
{
exit 0
}
else
{
start-sleep -s 60
$retry2 ++
write-output "Retrying $retry2"
}
}
exit 1
Hi Tim,
Thanks for sharing the information, and is useful for others.
Thanks,
Eswar
Im confused what the empty CMclient.txt file is for? Its not referenced in the script or anywhere else. Typo?
Hi Jonathan,
Yes, it is typo. please ignore it ,and thanks for the notice 🙂
Regards,
Eswar
Nice Post buddy.
Just wanted to understand what did you mean by install ccmsetp.exe with /source and other switches to assign it to site.
Hi,
the switches i was referring to the ccmsetup.exe available in configuration manager documentation https://docs.microsoft.com/en-us/mem/configmgr/core/clients/deploy/about-client-installation-properties
Thanks
Eswar
Actually I wanted to know if we have to manually install the client in the machine from the temp folder and then use the powershell script.
Hi.
If you are using intune to deploy the client and do co-mgmt,you can follow the blog post.
if you want to install client manually and without need of intune, then you can follow this blog post http://eskonr.com/2019/07/how-to-install-sccm-client-from-microsoft-intune-for-co-managed-and-cmg-notes-from-the-field/ where i talked about how to install the client manually
What is your request here?
Thanks,
Eswar