Created
August 2, 2023 17:25
-
-
Save hishaamn/4ab6072bf47e812c548b424311b2e4c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dialogProps = @{ | |
Title = "Version Lister" | |
Description = "The dialog allows the selection whether to see all versions or only the latest" | |
Width = 500 | |
Height = 100 | |
OkButtonName = "OK" | |
CancelButtonName = "Cancel" | |
Parameters = @( | |
@{ Name = "onlyLatest"; Value=$true; Title="Show only latest versions"; Editor="checkbox"; } | |
) | |
} | |
$result = Read-Variable @dialogProps | |
if($result -ne "ok") { | |
Exit | |
} | |
$items = $null | |
if($onlyLatest){ | |
$allVersionItems = Get-Item . -Language * -Version * | |
$items = $allVersionItems.Versions.GetLatestVersion(); | |
} else{ | |
$items = $allVersionItems; | |
} | |
$processedItems = @(); | |
$results = @(); | |
foreach($item in $items){ | |
Write-Host "Item $($item.Name) with Language $($item.Language) and version number $($item.Version.Number)" | |
$key = $item.Name + "-" + $item.Language + "-" + $item.Version.Number | |
if($processedItems -NotContains $key){ | |
$properties = @{ | |
ID = $item.ID | |
Name = $item.Name | |
Language = $item.Language | |
Version = $item.Version.Number | |
LastUpdated = $item.Fields["__Updated"].Value | |
LastUpdatedBy = $item.Fields["__Updated by"].Value | |
} | |
$results += New-Object psobject -Property $properties | |
$processedItems += $key | |
} | |
} | |
$results | Show-ListView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment