Skip to content

Commit

Permalink
v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jul 18, 2019
1 parent 922201d commit cdf37e4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 30 deletions.
7 changes: 6 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log for PSReleaseTools

## 1.3.1
## v1.3.2

+ Fixed another new bug with installation commands
+ Standardized verbose output to include a timestamp

## v1.3.1

+ Fixed installation issue with spaces in filenames (Issue #13)

Expand Down
Binary file modified PSReleaseTools.psd1
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ Install-Module PSReleaseTools -scope currentuser

I have a few other ideas for commands I might add to this module. If you have suggestions or encounter problems, please post an issue in the GitHub repository.

Last updated 2019-07-18 13:35:25Z UTC
Last Updated 2019-07-18 18:07:49Z UTC
23 changes: 15 additions & 8 deletions functions/private.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Function DL {
[cmdletbinding(SupportsShouldProcess)]
Param([string]$Source, [string]$Destination, [string]$hash, [switch]$Passthru)

Write-Verbose "[$($myinvocation.mycommand)] $Source to $Destination"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] $Source to $Destination"

if ($pscmdlet.ShouldProcess($Destination, "Downloading $source")) {
Invoke-Webrequest -Uri $source -UseBasicParsing -DisableKeepAlive -OutFile $Destination
Write-Verbose "[DL] Comparing file hash to $hash"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Comparing file hash to $hash"
$f = Get-FileHash -Path $Destination -Algorithm SHA256
if ($f.hash -ne $hash) {
Write-Warning "Hash mismatch. $Destination may be incomplete."
Expand All @@ -29,15 +29,15 @@ Function GetData {

$uri = "https://api.github.com/repos/powershell/powershell/releases"

Write-Verbose "[$($myinvocation.mycommand)] Getting current release information from $uri"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting current release information from $uri"
$get = Invoke-Restmethod -uri $uri -Method Get -ErrorAction stop

if ($Preview) {
Write-Verbose "[$($myinvocation.mycommand)] Getting latest preview"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting latest preview"
($get).where( {$_.prerelease}) | Select-Object -first 1
}
else {
Write-Verbose "[$($myinvocation.mycommand)] Getting latest stable release"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Getting latest stable release"
($get).where( { -NOT $_.prerelease}) | Select-Object -first 1
}
}
Expand All @@ -52,14 +52,21 @@ Function InstallMsi {
[string]$Mode = "Full"
)

Write-Verbose "[$($myinvocation.mycommand)] Creating install command for $Path"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Creating install command for $Path"

$cmd = "Start-Process -filepath '$Path' -argumentlist '/$mode'"
Write-Verbose "[$($myinvocation.mycommand)] Using $Mode mode"
switch ($Mode) {
"Full" { $installParam = "/qf" }
"Quiet" { $installparam = "/quiet"}
"Passive" {$installParam = "/passive"}
}
$cmd = "Start-Process -filepath '$Path' -argumentlist '$installParam'"
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] $cmd"
$sb = [scriptblock]::Create($cmd)

if ($pscmdlet.ShouldProcess($sb)) {
Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Invoking command"
Invoke-Command -scriptblock $sb
}

Write-Verbose "[$((Get-Date).TimeofDay) $($myinvocation.mycommand)] Ending function"
} #close installmsi
40 changes: 20 additions & 20 deletions functions/public.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Function Get-PSReleaseCurrent {
)

Begin {
Write-Verbose "[BEGIN ] Starting: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"

} #begin

Expand Down Expand Up @@ -36,7 +36,7 @@ Function Get-PSReleaseCurrent {
} #process

End {
Write-Verbose "[END ] Ending: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.Mycommand)"
} #end

}
Expand All @@ -53,7 +53,7 @@ Function Get-PSReleaseSummary {
)

Begin {
Write-Verbose "[BEGIN ] Starting: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"
} #begin

Process {
Expand Down Expand Up @@ -112,7 +112,7 @@ $($DL | Out-String)
} #process

End {
Write-Verbose "[END ] Ending: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.Mycommand)"
} #end

}
Expand Down Expand Up @@ -157,14 +157,14 @@ Function Save-PSReleaseAsset {


Begin {
Write-Verbose "[BEGIN ] Starting: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"
} #begin

Process {
Write-Verbose "[PROCESS] Using Parameter set $($PSCmdlet.ParameterSetName)"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Using Parameter set $($PSCmdlet.ParameterSetName)"

if ($PSCmdlet.ParameterSetName -match "All|Family") {
Write-Verbose "[PROCESS] Getting latest releases from $uri"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting latest releases from $uri"
Try {
$data = Get-PSReleaseAsset -Preview:$Preview -ErrorAction Stop
}
Expand All @@ -177,16 +177,16 @@ Function Save-PSReleaseAsset {

Switch ($PSCmdlet.ParameterSetName) {
"All" {
Write-Verbose "[PROCESS] Downloading all releases to $Path"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Downloading all releases to $Path"
foreach ($asset in $data) {
Write-Verbose "[PROCESS] ...$($Asset.filename) [$($asset.hash)]"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] ...$($Asset.filename) [$($asset.hash)]"
$target = Join-Path -Path $path -ChildPath $asset.filename
DL -source $asset.url -Destination $Target -hash $asset.hash -passthru:$passthru
}
} #all
"Family" {
#download individual release files
Write-Verbose "[PROCESS] Downloading releases for $($family -join ',')"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Downloading releases for $($family -join ',')"
$assets = @()
Foreach ($item in $Family) {

Expand All @@ -205,19 +205,19 @@ Function Save-PSReleaseAsset {

if ($PSBoundParameters.ContainsKey("Format")) {
$type = $PSBoundParameters["format"] -join "|"
Write-Verbose "[PROCESS] Limiting download to $type files"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Limiting download to $type files"
$assets = $assets.Where( {$_.filename -match "$type$"})
}

foreach ($asset in $Assets) {
Write-Verbose "[PROCESS] ...$($Asset.filename) [$($asset.hash)]"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] ...$($Asset.filename) [$($asset.hash)]"
$target = Join-Path -Path $path -ChildPath $asset.fileName
DL -source $asset.url -Destination $Target -hash $asset.hash -passthru:$passthru
} #foreach asset
} #foreach family name
} #Family
"File" {
Write-Verbose "[PROCESS] ...$($asset.filename) [$($asset.hash)]"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] ...$($asset.filename) [$($asset.hash)]"
$target = Join-Path -Path $path -ChildPath $asset.fileName
DL -source $asset.url -Destination $Target -hash $asset.hash -passthru:$passthru
} #file
Expand All @@ -226,7 +226,7 @@ Function Save-PSReleaseAsset {
} #process

End {
Write-Verbose "[END ] Ending: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.Mycommand)"
} #end
}

Expand All @@ -247,7 +247,7 @@ Function Get-PSReleaseAsset {
)

Begin {
Write-Verbose "[BEGIN ] Starting: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"
} #begin

Process {
Expand All @@ -267,7 +267,7 @@ Function Get-PSReleaseAsset {
$h.add($_.groups["file"].value.trim(), $_.groups["hash"].value.trim())
}

Write-Verbose "[PROCESS] Found $($data.assets.count) downloads"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Found $($data.assets.count) downloads"

$assets = $data.assets |
Select-Object @{Name = "FileName"; Expression = {$_.Name}},
Expand Down Expand Up @@ -298,16 +298,16 @@ Function Get-PSReleaseAsset {
@{Name = "DownloadCount"; Expression = {$_.download_count}}

if ($Family) {
Write-Verbose "[PROCESS] Filtering by family"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering by family"
$assets = $assets.where( {$_.family -match $($family -join "|")})
}
if ($Only64Bit) {
Write-Verbose "[PROCESS] Filtering for 64bit"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering for 64bit"
$assets = ($assets).where( {$_.filename -match "(x|amd)64"})
}

if ($Format) {
Write-Verbose "[PROCESS] Filtering for format"
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Filtering for format"
$assets = $assets.where( {$_.format -match $($format -join "|")})
}
#write the results to the pipeline
Expand All @@ -320,7 +320,7 @@ Function Get-PSReleaseAsset {
} #process

End {
Write-Verbose "[END ] Ending: $($MyInvocation.Mycommand)"
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.Mycommand)"
} #end
}

Expand Down

0 comments on commit cdf37e4

Please sign in to comment.