I tried to build a commandlet that could interpret the Dism Output of -GetPackage, which should be achievable with the Cmdlet Get-WindowsPackage in Powershell. The Output does not contain anything i could use and i do not know, whether i just don't know
the right function to find out the name of the Installed packages or whether my approach is fundamentally flawed.
I Apologize for any bad practice, i only heard of Power Shell 2 Weeks ago and tried to do something i did with Dism in a faster and easier way.
This is the Code i currently use, followed by an example of what my output loooks like.
<#
.Synopsis
Slipstreams Updates Into a Windowsimage
.DESCRIPTION
A Commandlet in Powershell that adds every update in a directory to a .wim Windows image.
.EXAMPLE
Slipstream-WindowsImage -ImagePath C:\Images\windowsimage.wim -Index 1 -PackagePath C:\Packages\updates -MountPath C:\mount\windows
#>
function Slipstream-WindowsUpdate
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# ImagePath should call a WINdows Image File. The Variable is used only by Mount-Windowsimage and should accept any File that meets that Commandlets conditions.
[Parameter(Mandatory=$true)]
[String]$ImagePath,
# Use Index to point to a Partition of the Windows Image. Slipstream-WindowsUpdate does not Permit Multiple Indices due to the Time it takes it to Update even a Single partition.
[Parameter(Mandatory=$true)]
[int]$Index,
# Specify where the .cab Update files lie in your Folder Structure using this Variable.
[Parameter(Mandatory=$true)]
[Alias('PackagePath','UpdatePath')]
[String]$PackagePathCab,
# Specify a directory containing preferably not already installed .msu updates. It is Impossible for me to check their installation status, shich shouldn't break the Image but Takes unnecessary amounts of your Time.
[Parameter()]
[String]$PackagePathMsu,
# if used this Commandlet will create three logfiles for unnecessary, failed and successfull updates on your Machine.
[Parameter()]
[Switch]$Log,
# using this Parameter one can define a Logpath. If not specified the Logpath will be "C:\Users\Public\Documents".
[Parameter()]
[String]$LogPath = "C:\Users\Public\Documents",
# THe Commandlet uses Mount- and Dismount-WindowsImage, Therefore it needs a free Folder to Mount to and Dismount from after the Updates are done. This Variable holds the Directory and is, of course, Mandatory.
[Parameter(Mandatory=$true)]
[Alias('Path')]
[String]$MountPath
)
Begin
{
$Cabs = Get-ChildItem -Path $PackagePathCab -recurse -Include *.cab | Sort LastWriteTime
Write-Host 'Currently the main functionality of this Commandlet is commented out because of a bug the Developer could not Resolve, any User is Free to edit or uncomment the code for basic functionality.'
Mount-WindowsImage -ImagePath $ImagePath -Index $Index -Path $MountPath -CheckIntegrity
}
Process
{
ForEach ($Cab in $Cabs) {
Write-Host $Cab
Get-WindowsPackage -Path $MountPath -PackagePath $Cab -OutVariable Temp
Write-Host $Temp
Write-Host $?
$Temp | dir
$Temp
# if ($? -eq $true){
# $Cab.Name | Out-File -FilePath $LogPath\Updates-Unnecessary.log -Append
# } else {
# Add-WindowsPackage -Path C:\Mount -PackagePath $Cab.FullName
# if ($? -eq $TRUE){
# $Cab.Name | Out-File -FilePath $LogPath\Updates-Sucessful.log -Append
# } else {
# $Cab.Name | Out-File -FilePath $LogPath\Updates-Failed.log -Append
# }
# }
}
}
End
{
Dismount-WindowsImage –Path $MountPath –Discard
}
}
PS C:\Windows\system32> Slipstream-WindowsUpdate -ImagePath C:\Img\MASTER.wim -PackagePathCab C:\Imgupdt\w63-x64 -MountPath C:\mount\offline -Log $true -LogPath C:\Img -Index 3
Currently the main functionality of this Commandlet is commented out because of a bug the Developer could not Resolve, any User is Free to edit or u
ncomment the code for basic functionality.
Path : C:\mount\offline
Online : False
Restart Needed : False
C:\Imgupdt\w63-x64\glb\windows6.1-kb2393802-x64_1eba297f187b449686436c1071edf2312804a4e3.cab
Path : C:\mount\offline
Online : False
Restart Needed : False
Microsoft.Dism.Commands.AdvancedPackageObject
True
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline\PerfLogs
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline
PSChildName : PerfLogs
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : PerfLogs
Parent : offline
Exists : True
Root : C:\
FullName : C:\mount\offline\PerfLogs
Extension :
CreationTime : 22.08.2013 17:36:30
CreationTimeUtc : 22.08.2013 15:36:30
LastAccessTime : 22.08.2013 17:22:35
LastAccessTimeUtc : 22.08.2013 15:22:35
LastWriteTime : 22.08.2013 17:22:35
LastWriteTimeUtc : 22.08.2013 15:22:35
Attributes : Directory
BaseName : PerfLogs
Mode : d----
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline\Program Files
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline
PSChildName : Program Files
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : Program Files
Parent : offline
Exists : True
Root : C:\
FullName : C:\mount\offline\Program Files
Extension :
CreationTime : 22.08.2013 15:36:15
CreationTimeUtc : 22.08.2013 13:36:15
LastAccessTime : 22.11.2014 07:33:38
LastAccessTimeUtc : 22.11.2014 06:33:38
LastWriteTime : 22.11.2014 07:33:38
LastWriteTimeUtc : 22.11.2014 06:33:38
Attributes : ReadOnly, Directory
BaseName : Program Files
Mode : d-r--
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline\Program Files (x86)
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline
PSChildName : Program Files (x86)
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : Program Files (x86)
Parent : offline
Exists : True
Root : C:\
FullName : C:\mount\offline\Program Files (x86)
Extension :
CreationTime : 22.08.2013 15:36:15
CreationTimeUtc : 22.08.2013 13:36:15
LastAccessTime : 22.08.2013 17:36:33
LastAccessTimeUtc : 22.08.2013 15:36:33
LastWriteTime : 22.08.2013 17:36:33
LastWriteTimeUtc : 22.08.2013 15:36:33
Attributes : ReadOnly, Directory
BaseName : Program Files (x86)
Mode : d-r--
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline\Users
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline
PSChildName : Users
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : Users
Parent : offline
Exists : True
Root : C:\
FullName : C:\mount\offline\Users
Extension :
CreationTime : 22.08.2013 15:36:15
CreationTimeUtc : 22.08.2013 13:36:15
LastAccessTime : 22.11.2014 08:00:56
LastAccessTimeUtc : 22.11.2014 07:00:56
LastWriteTime : 22.11.2014 08:00:56
LastWriteTimeUtc : 22.11.2014 07:00:56
Attributes : ReadOnly, Directory
BaseName : Users
Mode : d-r--
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline\Windows
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\mount\offline
PSChildName : Windows
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : Windows
Parent : offline
Exists : True
Root : C:\
FullName : C:\mount\offline\Windows
Extension :
CreationTime : 22.08.2013 15:36:15
CreationTimeUtc : 22.08.2013 13:36:15
LastAccessTime : 22.11.2014 08:00:57
LastAccessTimeUtc : 22.11.2014 07:00:57
LastWriteTime : 22.11.2014 08:00:57
LastWriteTimeUtc : 22.11.2014 07:00:57
Attributes : Directory
BaseName : Windows
Mode : d----
Path : C:\mount\offline
Online : False
Restart Needed : False
C:\Imgupdt\w63-x64\glb\windows8.1-kb2876331-x64_f84e3a6c86e0a9bc4108d8b38d7349d0e0798c79.cab
Path : C:\mount\offline
Online : False
Restart Needed : False
Microsoft.Dism.Commands.AdvancedPackageObject
True