Skip to content

Commit

Permalink
Fixes and Docs
Browse files Browse the repository at this point in the history
Fixes AdamGrossTX#1 and AdamGrossTX#2 and adds help/docs
  • Loading branch information
AdamGrossTX committed Jul 28, 2020
1 parent 91e280d commit a0f6863
Show file tree
Hide file tree
Showing 18 changed files with 2,206 additions and 44 deletions.
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,19 @@ Setup-FUModule.ps1
newbuild.ps1
getblocks.ps1
bin
workspace.*
workspace.*
sdb2xml/sdb2xml.csproj
sdb2xml/sdb2xml.sln
sdb2xml/.vs/sdb2xml/v16/.suo
sdb2xml/Microsoft.AppCompat/Pdb.cs
sdb2xml/Microsoft.AppCompat/Program.cs
sdb2xml/Microsoft.AppCompat/ShimDatabase.cs
sdb2xml/Microsoft.AppCompat/Tag.cs
sdb2xml/Microsoft.AppCompat/Interop/NativeMethods.cs
sdb2xml/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs
sdb2xml/obj/Debug/sdb2xml.csproj.CoreCompileInputs.cache
sdb2xml/obj/Debug/sdb2xml.csproj.FileListAbsolute.txt
sdb2xml/obj/Debug/sdb2xml.csprojAssemblyReference.cache
sdb2xml/Properties/AssemblyInfo.cs
sdb2xml/sdb2xmlReferences/System.dll
sdb2xml/sdb2xmlReferences/System.Xml.dll
54 changes: 28 additions & 26 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,46 @@ try {


#region Generate a new version number
$moduleName = Split-Path $modulePath -Leaf
[Version]$exVer = Find-Module $moduleName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Version
$moduleName = Split-Path -Path $modulePath -Leaf
[Version]$exVer = Find-Module -Name $moduleName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Version
if ($buildLocal) {
$rev = ((Get-ChildItem $PSScriptRoot\bin\release\ -ErrorAction SilentlyContinue).Name | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum) + 1
$newVersion = New-Object Version -ArgumentList 1, 0, 0, $rev
$rev = ((Get-ChildItem -Path "$($PSScriptRoot)\bin\release\" -ErrorAction SilentlyContinue).Name | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum) + 1
$newVersion = New-Object -TypeName Version -ArgumentList 1, 0, 0, $rev
}
else {
$newVersion = if ($exVer) {
$rev = ($exVer.Revision + 1)
New-Object version -ArgumentList $exVer.Major, $exVer.Minor, $exVer.Build, $rev
}
else {
$rev = ((Get-ChildItem $PSScriptRoot\bin\release\ -ErrorAction SilentlyContinue).Name | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum) + 1
$rev = ((Get-ChildItem "$($PSScriptRoot)\bin\release\" -ErrorAction SilentlyContinue).Name | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum) + 1
New-Object Version -ArgumentList 1, 0, 0, $rev
}
}
$releaseNotes = (Get-Content .\$moduleName\ReleaseNotes.txt -Raw -ErrorAction SilentlyContinue).Replace("{{NewVersion}}",$newVersion)
$releaseNotes = (Get-Content ".\$($moduleName)\ReleaseNotes.txt" -Raw -ErrorAction SilentlyContinue).Replace("{{NewVersion}}",$newVersion)
$releaseNotes = $exVer ? $releaseNotes.Replace("{{LastVersion}}","$($exVer.ToString())") : $releaseNotes.Replace("{{LastVersion}}","")
#endregion

#region Build out the release
$relPath = "$PSScriptRoot\bin\release\$rev\$moduleName"
"Version is $newVersion"
"Module Path is $modulePath"
"Module Name is $moduleName"
"Release Path is $relPath"
if (!(Test-Path $relPath)) {
$relPath = "$($PSScriptRoot)\bin\release\$($rev)\$($moduleName)"
"Version is $($newVersion)"
"Module Path is $($modulePath)"
"Module Name is $($moduleName)"
"Release Path is $($relPath)"
if (!(Test-Path -Path $relPath)) {
New-Item -Path $relPath -ItemType Directory -Force | Out-Null
}

Copy-Item "$modulePath\*" -Destination "$relPath" -Recurse -Exclude ".gitKeep","releaseNotes.txt","description.txt","*.psm1","*.psd1"
Copy-Item -Path "$($modulePath)\*" -Destination "$($relPath)" -Recurse -Exclude ".gitKeep","releaseNotes.txt","description.txt","*.psm1","*.psd1"

$Manifest = @{
Path = "$($relPath)\$($ModuleName).psd1"
RootModule = "$($ModuleName).psm1"
Author = $Author
CompanyName = $CompanyName
ModuleVersion = $newVersion
Description = (Get-Content .\$moduleName\description.txt -raw).ToString()
FunctionsToExport = (Get-ChildItem -Path ("$ModulePath\Public\*.ps1") -Recurse).BaseName
Description = (Get-Content ".\$($moduleName)\description.txt" -raw).ToString()
FunctionsToExport = (Get-ChildItem -Path ("$($ModulePath)\Public\*.ps1") -Recurse).BaseName
DefaultCommandPrefix = $Prefix.ToUpper()
CmdletsToExport = @()
VariablesToExport = '*'
Expand All @@ -82,6 +82,7 @@ $ModuleFunctionScript = "
SDBUnPackerFile = Join-Path -Path `$PSScriptRoot -ChildPath `"SDBUnpacker.py`"
sdb2xmlPath = Join-Path -Path `$PSScriptRoot -ChildPath `"sdb2xml.exe`"
UserConfigFile = `"`$(`$env:USERPROFILE)\.`$(`$script:Prefix)cfgpath`"
PythonPath = `$env:Path.split(';') | Where-Object {`$_ -Like `"*Python*`" -and `$_ -notlike `"*scripts*`"}
}
`$cfg = Get-Content `$initCfg[`"UserConfigFile`"] -ErrorAction SilentlyContinue
`$script:tick = [char]0x221a
Expand Down Expand Up @@ -110,20 +111,21 @@ $ModuleFunctionScript = "
}
#endregion
Try {
`$pythonVersion = & python --version
If(`$pythonVersion) {
[switch]`$script:PythonInstalled = `$true
}
Else {
Throw `"Python is not installed. Install Pyton before proceeding.`"
}
If(`$Script:Config.PythonPath -and (Test-Path -Path `"`$(`$Script:Config.PythonPath)`")) {
`$PythonVersion = & `"`$(`$Script:Config.PythonPath)\python.exe`" --version
}
Catch {
[switch]`$script:PythonInstalled = `$false
Write-Warning `$_.Exception.Message
Else {
`$PythonVersion = & python --version
}
If(`$pythonVersion) {
[switch]`$script:PythonInstalled = `$true
}
Else {
Throw `"Python is not installed. Install Pyton before proceeding.`"
}
"
$ModuleFunctionScript | Out-File -FilePath "$($relPath)\$($ModuleName).psm1" -Encoding utf8 -Force

Expand Down
7 changes: 6 additions & 1 deletion FU.WhyAmIBlocked/Private/Get-PythonVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ function Get-PythonVersion {
[cmdletbinding()]
Param()
Try {
$PythonVersion = & python --version
If($Script:Config.PythonPath) {
$PythonVersion = & $($Script:Config.PythonPath)\python.exe --version
}
Else {
$PythonVersion = & python --version
}
Return $PythonVersion
}
Catch {
Expand Down
4 changes: 2 additions & 2 deletions FU.WhyAmIBlocked/Public/Get-Blocks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Function Get-Blocks {
Try {

Write-Host " + Creating Output Folders $($OutputPath).. " -ForegroundColor Cyan -NoNewline
[System.Collections.ArrayList]$Script:BlockList = @()


If($Local.IsPresent -or (!($DeviceName)) -and (!($AlternateSourcePath))) {
$DeviceName = $env:computername
Expand Down Expand Up @@ -98,7 +98,7 @@ Function Get-Blocks {
}

$HumanReadableXMLFiles = (Get-Item -Path "*Humanreadable.xml" -ErrorAction SilentlyContinue).FullName
$Script:BlockList = Get-BlocksFromXML -FileList $HumanReadableXMLFiles -ResultFile $ResultFile
$Script:BlockList = Get-BlocksFromBin -FileList $HumanReadableXMLFiles -ResultFile $ResultFile -Output (New-Object -TypeName System.Collections.ArrayList )

#Needs to work with remote devices too...
If($DeviceName -eq $env:computername) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Function Get-BlocksFromXML {
Function Get-BlocksFromBin {
[cmdletbinding()]
Param (
[parameter(Position = 1, Mandatory = $true)]
[string[]]
$FileList,

[string]
$ResultFile = ".\Result.txt"
$ResultFile = ".\Result.txt",
[System.Collections.ArrayList]$Output
)

Try {
[System.Collections.ArrayList]$BlockList = @()

If(!(Test-Path -Path $ResultFile)) {
New-Item -Path $ResultFile -ItemType File | Out-Null
}
Expand Down Expand Up @@ -60,13 +61,13 @@ Function Get-BlocksFromXML {
$gBlock = ForEach($num in $ordinal) {
$sdb[$x] | Where-Object Ordinal -EQ $num
}
($gBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$BlockList.Add($_) | Out-Null}
($gBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$Output.Add($_) | Out-Null}
$gBlock | Out-File -FilePath $ResultFile -Append

}
If($ordinal.Count -eq 1) {
$gBlock = $sdb[$x] | Where-Object Ordinal -EQ $ordinal
($gBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$BlockList.Add($_) | Out-Null}
($gBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$Output.Add($_) | Out-Null}
$gBlock | Out-File -FilePath $ResultFile -Append
}

Expand All @@ -91,12 +92,12 @@ Function Get-BlocksFromXML {
$sBlock = ForEach($num in $ordinal) {
$sdb[$x] | Where-Object Ordinal -EQ $num
}
($sBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$BlockList.Add($_) | Out-Null}
($sBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$Output.Add($_) | Out-Null}
$sBlock | Out-File -FilePath $ResultFile -Append
}
Else {
$sBlock = $sdb[$x] | Where-Object Ordinal -EQ $ordinal
($sBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$BlockList.Add($_) | Out-Null}
($sBlock | Where-Object Name -eq "SdbEntryGuid" | Select -ExpandProperty Value) | ForEach-Object {$Output.Add($_) | Out-Null}
$sBlock | Out-File -FilePath $ResultFile -Append
}
$x++
Expand All @@ -123,7 +124,7 @@ Function Get-BlocksFromXML {
}
Write-Host " + Results output to $($ResultFile).. " -ForegroundColor Cyan -NoNewline
Write-Host $Script:tick -ForegroundColor green
Return $BlockList
Return $Output
}
Catch {
Write-Warning $_
Expand Down
18 changes: 15 additions & 3 deletions FU.WhyAmIBlocked/Public/Initialize-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@ function Initialize-Module {
[cmdletbinding()]
param (
[parameter(Position = 1, Mandatory = $false)]
$initCfg = $script:Config,
$initCfg,

[parameter(Position = 2, Mandatory = $false)]
[switch]
$Reset
)
try {

#Create output folder
$Path = $initCfg.Path
If($Reset.IsPresent) {
If($initcfg) {
$initCfg
}
Else {
$initCfg = $script:initCfg
}
}
Else {
$initCfg = $Script:Config
}

$path = $initCfg.Path
If(!(Test-Path -Path $Path)) {
New-Item -Path $Path -ItemType Directory | Out-Null
}


$ConfigFile =
If($initCfg.ConfigFile) {
$initCfg.ConfigFile
Expand Down
4 changes: 3 additions & 1 deletion FU.WhyAmIBlocked/description.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Can't get the latest Windows 10 Feature update? Need to find out what's blocking you? This module will help you find the block quickly!
Can't get the latest Windows 10 Feature update? Need to find out what's blocking you? This module will help you find the block quickly!

More details in my blog https://www.asquaredozen.com/2020/07/26/demystifying-windows-10-feature-update-blocks/
5 changes: 3 additions & 2 deletions GetBlocks.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Import-Module ".\FU.WhyAmIBlocked" -Force
Initialize-FUModule
Import-Module ".\bin\release\20\FU.WhyAmIBlocked" -Force
#Update-Module FU.WhyAmIBlocked
Initialize-FUModule -reset
Get-FUBlocks

#ToDo Usage Examples
Expand Down
Loading

0 comments on commit a0f6863

Please sign in to comment.