Silent Scripted PNP Driver Installation

Occasionally, you may find the need to push a new driver to computers.  Perhaps a driver is causing BSOD issues or whatever the reason.  Since DotNet does not have a direct way to do this, you are usually left with depending on the driver publisher to include an silent installation method.  In reality this rarely happens.  You definitely don’t want to run around and manually install the drivers, and tools like Configuration Manager don’t have support for post OS deployment of drivers.

Continue reading

Getting Physical Disk and Logical Disk Sizes

There are several use cases where it may be necessary to get the Physical Disk and Logical Disk (partition) sizes and free space. This information although easily accessible in WMI is stored in a format that is difficult to use.

These two functions should help you with that

Function Get-FreeSpace{
        [string]$computer = 'localhost',
        [string]$disk = 'C:'
    $LogicalDisks = gwmi -computername $computer -query "select * from win32_logicaldisk where deviceid='${disk}'"
    ForEach($LogicalDisk in $LogicalDisks){ 
        [pscustomobject]@{'Caption'=$LogicalDisk.caption;'Size (GB)'=$('{0:N2}' -f [double]($LogicalDisk.size/1gb));'Free (GB)'=$('{0:N2}' -f [double]($LogicalDisk.FreeSpace/1gb))}

Get-FreeSpace -computer localhost -disk 'c:'
# Output
# Caption Free (GB) Size (GB)
# ------- --------- ---------
# C:      19.38     119.24   

Function Get-PhysicalDiskSize{
        [string]$computer = 'localhost'
    $Disks = gwmi -ComputerName $computer -query "Select Index,Size,MediaType From win32_DiskDrive"
    ForEach($Disk in $Disks){
        [pscustomobject]@{"Index"=$Disk.index;"Size (GB)"=([Double]([MATH]::Round(([double]$Disk.Size / 1073741824),2)));"MediaType"=$disk.mediatype}

Get-PhysicalDiskSize -computer 'localhost'
# Output
#Index Size (GB) MediaType            
#----- --------- ---------            
#    1    465.76 Fixed hard disk media
#    0    119.24 Fixed hard disk media

ConfigMgr Client Fails to Install: Unable to Compile UpdatesAgent.mof

We’ve had a couple of computers in the past being unable to re-install the Configuration Manager client due to the error:
“Unable to compile UpdatesAgent.mof”

This error can have a couple of different causes.

As such, here are a couple of steps you can try:

1. Reinstall the Windows Update agent.
2. Uninstall any existing ConfigMgr client, stop the ccmsetup service and delete c:\windows\ccm, c:\windows\ccmsetup and c:\windows\ccmcache folders
3. Run the following commands to delete the ConfigMgr namespaces completely from WMI:

Gwmi –query “Select * from __Namespace Where Name=’sms’” –NameSpace “root\cimv2” | Remove-WmiObject
Gwmi –query “Select * from __Namespace Where Name=’ccm’” –NameSpace “root” | Remove-WmiObject
Gwmi –query “Select * from __Namespace Where Name=’smsdm’” –NameSpace “root” | Remove-WmiObject

Since #3 is quite drastic, you will want to try steps 1 and 2 first before 3. However if attempting step 3, you will want to complete both steps 2 and 3 together. After this, the ConfigMgr client should successfully install.

Hopefully this helps!