Categories
Business Central Docker Dynamics NAV HOW TO Microsoft PowerShell

HOW TO remove docker dangling and unused images

Let us extend the concept of Spring Cleaning to our computers, virtual machines and servers where we are using Docker.

I was starting writing some PowerShell script from the list of the docker images

PS C:\> docker images

and thinking which filters to apply when I thought that maybe docker contains already a command that does some good cleanup.

Here the result of my research, we can use docker image prune, in my case I added also the parameters -a to remove all unused images (all images without at least one container associated to them) and -f that stands for Force to do not prompt for confirmation:

PS C:\> docker image prune -a -f

Note: every docker image related to Microsoft Dynamics NAV or Microsoft Dynamics 365 Business Central takes usually 10-20 GB of space.

If you use navcontainerhelper for the creation of the Docker containers I suggest you to have a look also of the content of the folder under the following path:

C:\ProgramData\NavContainerHelper

You could find old database backup or source file objects downloaded that could be deleted as well.

Did my HOW TO help you? Leave a reply.

Categories
HOW TO Microsoft PowerShell Windows 10 Windows 7 Windows 8 / 8.1 Windows Server 2008 Windows Server 2012 Windows Vista Windows XP

HOW TO get a list of pending Windows Updates of a Server with No Internet access using PowerShell

To get a list of pending Windows Updates of a Server with No Internet access, follow these steps:

  1. Download wsusscn2.cab from another pc/server with Internet Access
  2. Copy the wsusscn2.cab file in the Server that has No Internet access
  3. Open Windows PowerShell ISE as Administrator
  4. Run following PowerShell script assigning to the variable $Wsusscn2FilePath the correct path where you saved the wsusscn2.cab file
$Wsusscn2FilePath = "c:\tempwsusscn2.cab"

$UpdateSession = New-Object -ComObject Microsoft.Update.Session  
$UpdateServiceManager  = New-Object -ComObject Microsoft.Update.ServiceManager  
$UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", $Wsusscn2FilePath, 1)  
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()   
  
Write-Output "Searching for updates... `r`n"  
  
$UpdateSearcher.ServerSelection = 3 
 
$UpdateSearcher.IncludePotentiallySupersededUpdates = $true 
  
$UpdateSearcher.ServiceID = $UpdateService.ServiceID.ToString()  
  
$SearchResult = $UpdateSearcher.Search("IsInstalled=0") 
  
$Updates = $SearchResult.Updates  
  
if($Updates.Count -eq 0){  
    Write-Output "There are no applicable updates."  
    return $null  
}  
  
Write-Output "List of applicable items on the machine when using wssuscan.cab: `r`n"  
  
$i = 0  
foreach($Update in $Updates){   
    Write-Output "$($i)> $($Update.Title)"  
    $i++  
}

The script will return the list of pending updates or the message “There are no applicable updates”.

You will need to download manually the updates from another pc/server with Internet access, copy and install them manually as described in my previous post:

The steps have been tested in Windows Server 2016.

Sources:
Using WUA to Scan for Updates Offline
Using WUA to Scan for Updates Offline with PowerShell

Did my HOW TO help you? Leave a reply.