Monthly Archives: February 2017

How to Configure or Clear SCCM Client Cache

If you need to clear the SCCM client cache or increase the cache size on individual clients, there are a few different ways to do it. One of the methods usually posted on a lot of blogs and forums is actually the wrong way to do it, because it requires restarting the CCMEXEC process on the client in order to update the new cache settings, which makes the task sequence used to deploy the script fail since CCMEXEC, which was running the deployment, has been terminated.

Here I will show you the right way to clear the CCM cache that does not require restarting the CCMEXEC process. This PowerShell script can be deployed with SCCM as a package or as part of a task sequence. Sometimes this method is preferable to using Right Click Tools, especially if you want to only change cache settings during application deployment, such as part of a task sequence that installs multiple large applications. Sometimes it doesn’t make sense to keep 30GB of installers cached on the computer and it’s better to just manually flush the cache after the installation completes.

Here is the script to clear the ccmcache:

Continue reading

How to enable DHCP using PowerShell

Enabling DHCP using PowerShell is very easy and can be accomplished in three lines of code. Yet for some reason many other online guides show the long way around.

I previously posted about how to set static IP’s using PowerShell. This script to enable DHCP can be a complementary program inside an SCCM package to configure IP addresses. That way, you can have an SCCM program to deploy a static IP and then another program to reset it back to DHCP, and both of these programs can be inside one package.

Alternatively, this script can be used as an Uninstall method if setting static IP’s using an application in SCCM, with a modified version of my network adapter configuration detection method script as the application detection method.

Either way, here is the short and simple script, with a log file output designed to add on to the previously mentioned Static IP script’s logs if they exist:

Continue reading

Programmatically Setting Static IP’s in a Computer Lab

If your organization has computer labs which require static IP addresses, here is a very easy method to deploy static IP’s to each lab. Most labs will have some sort of numbering scheme as part of the computer name. We can take advantage of this in order to transform the computer number into an IP address.

In my example, the computer number is at the end of the computer name. I am going to use PowerShell to calculate the new IP address for each computer, apply the new network configuration, register the new settings, and output a log file. Here is the script:

Continue reading

How to Crawl Websites to Download Software Updates with PowerShell

I wrote this script to check for updates to some common software used in my organization. In order to do so, the script uses PowerShell to crawl the website of each piece of software so that it can get the software version number and download link. The script compares the version of the software it found online to the version it found in the local folder inside the script directory. If the version online is newer, it downloads the file and renames it to a nice format including the version number. The software (64-bit where available) crawled for download is:

  • 7-Zip
  • Google Chrome
  • Mozilla Firefox
  • Mozilla Firefox ESR
  • Adobe Flash Player ActiveX
  • Adobe Flash Player NPAPI Plugin
  • Java
  • VLC Media Player

I figured this script would be a good example to share because it uses a few different methods to find the information it needs on each publisher’s website. Some people can find these examples helpful to modify the code to crawl for something else. In the case of Adobe Flash Player for enterprise distribution, the website requires a login, so I just left the script to check the version and then open a browser window going to the login screen so that the user can manually download the MSI files. Since the Adobe enterprise distribution license says the download link cannot be shared, I have edited it out of the script, so you will need to replace it yourself if you want to use this function. Just search for all instances of “https://INSERT-ADOBE-DISTRIBUTION-LINK-HERE” and replace it with the URL you received from Adobe.

I split this script into functions, with a function to download the software and a separate function to crawl the website for each piece of software. Inside of each crawl function, I split the variables and crawl methods that need modification. This also means that you can remove the last part of the script after line 315 if you would rather use the script to manually call each function using the PowerShell console in order to check for just one piece of software.

Again, this script is very application-specific, so unless you need to check for updates and download this specific set of software, you will need to modify the script for whatever software you need. Use it as a very broad example of crawling the web with PowerShell. There are many different ways to do this, and I’m sure some might be better, but this way works exactly as I need it to for my specific use case. And of course if a website for a particular piece of software changes, the crawl function for that software will break, but there’s no way around that with web crawling.

Here is the required directory structure for this specific set of software:

And here is the full PowerShell script:

Continue reading

Microsoft Updates Extractor PowerShell Script

I wrote this script in order to extract MSP files from CAB files. The purpose of this in my case was to get Office updates that already existed in SCCM and to put their MSP files into the Office installation folder’s “updates” directory in order to have the updates automatically installed when Office is installed.

There are a few scripts online that do this already, but they are much more complicated since they dig in to the SCCM database and download the CAB files from the management point themselves, among other unnecessary (in my case) tasks. I wanted a simpler script that I could run on my own machine rather than the SCCM server for security reasons, so I came up with this PowerShell script that does just that, including renaming the files to match their KB numbers.

The script requires an “msp” folder and an “updates” folder to reside in the same directory as the script. Since this script is run locally, you need to have the CAB files already on your computer. The CAB files from SCCM do not need to be moved out of their respective folders – you can simply copy them as-is from your SCCM updates folder. This means your “updates” folder in the script directory can have folders inside of it, and those folders will have the CAB files. Once complete, the extracted MSP files will all be together in the “msp” folder, ready to copy to your Office installation’s “updates” directory.

Here is the script:

Continue reading

How to Set DNS Suffix and Registration using PowerShell

This very simple PowerShell script can be used to set these options:

  • DNS Suffix for this connection
  • Register this connection’s addresses in DNS
  • Use this connection’s DNS suffix in DNS registration

I’ve seen many questions online on how to use a script to mark the two checkboxes in this “Advanced TCP/IP Settings” window.

So here is the very short and simple PowerShell script:

Continue reading

SCCM Application Detection Method for Network Adapter Configuration

I wrote this PowerShell script for use as an application detection method inside an SCCM application. The SCCM application would set the network adapter configuration if it is not currently configured properly. This company has a special DNS setup for SCCM clients that is different than for non-SCCM clients. Here is the PowerShell code:

Continue reading