Skip to content

Commit

Permalink
see changelog for v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Sep 28, 2018
1 parent 7fa89d9 commit 06ddf13
Show file tree
Hide file tree
Showing 13 changed files with 324 additions and 205 deletions.
81 changes: 81 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Changelog for PSTypeExtensionTools

## v1.2.0

- code cleanup
- markdown cleanup
- help cleanup
- Updates to `README.md`

## v1.1.0

- Fixed `Import-PSTypeExtension` bug piping in json/xml files (Issue #13)
- Updated About help documentation
- Modified pipeline processing in `Get-PSTypeExtension` (Issue #12)

## v1.0.0

- Modified `Export-PSTypeExtension` to export to a ps1xml file (Issue #11)
- release to the PowerShell Gallery
- Updated documentation
- Updated samples

## v0.5.1

- fixed bug in the CimInstance json sample
- fixed link bug in README.md file

## v0.5.0

- Modified `Get-PSType` to better reflect type names. (Issue #7)
- added additional sample files.
- modified `Get-PSTypeExtension` to include PSTypeExtension as a typename
- added format ps1xml (Issue #8)
- revised parameter validation for `Get-PSTypeExtension` (Issue #10)
- revised `Import-PSTypeExtension` to accept pipelined input for filenames (Issue #9)
- updated documentation

## v0.4.0

- Modified `Get-PSTypeExtension` so -All is the default (Issue #6)
- Modified `Get-PSTypeExtension` to validate typename
- Updated help documentation to include an About file
- Reverted Changelog to a text file
- Updated Strings sample file.

## v0.3.0

- fixed bug in `Get-PSTypeExtension` that was writing a blank object to the pipeline. (Issue #3)
- Added support for WhatIf to `Export-PSTypeExtension` (Issue #2)
- documentation update

## v0.2.0

- renamed commands for consistency with module name
- updated help documentation
- Added `Set-PSTypeExtension` as an alias to `Add-PSTypeExtension`

## v0.1.0

- major changes to functions and design
- Added `Get-PSType` function
- Added `Get-MyTypeExtension` function
- Added `Get-MyTypeExtension` function

## v0.0.4

- Updated to handle other member type (Issue #2)

## v0.0.3

- added ShouldSupportProcess for `Import-MyTypeExtension` (Issue #1)
- updated help
- updated manifest

## v0.0.2

- added a manifest

## v0.0.1

- Initial module
63 changes: 0 additions & 63 deletions Changelog.txt

This file was deleted.

Binary file modified PSTypeExtensionTools.psd1
Binary file not shown.
121 changes: 59 additions & 62 deletions PSTypeExtensionTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ Function Get-PSTypeExtension {
[cmdletbinding()]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Enter the name of type like System.IO.FileInfo",
ValueFromPipelineByPropertyName,ValueFromPipeline)]
ValueFromPipelineByPropertyName, ValueFromPipeline)]
[ValidateNotNullorEmpty()]
[ValidateScript({
#check if typename can be found with Get-TypeData
if ((get-typedata).typename -contains "$_") {
$True
}
elseif ($_ -as [type]) {
#test if string resolves as a typename
$True
}
else {
Throw "$_ does not appear to be a valid type."
}
})]
[ValidateScript( {
#check if typename can be found with Get-TypeData
if ((get-typedata).typename -contains "$_") {
$True
}
elseif ($_ -as [type]) {
#test if string resolves as a typename
$True
}
else {
Throw "$_ does not appear to be a valid type."
}
})]
[string]$TypeName,
[Parameter(HelpMessage = "Enter a comma separated list of member names", ParameterSetName = "members")]
[string[]]$Members
)

Begin {
Write-Verbose "Starting: $($MyInvocation.Mycommand)"
$typedata=@()
$typedata = @()
} #begin
Process {
Write-Verbose "Analyzing $typename"
Expand Down Expand Up @@ -110,7 +110,7 @@ Function Get-PSTypeExtension {

$def | Add-Member -MemberType NoteProperty -Name TypeName -Value $typedata.typename
#insert a typename
$def.psobject.typenames.insert(0,'PSTypeExtension')
$def.psobject.typenames.insert(0, 'PSTypeExtension')
#write the definition to the pipeline
Write-Output $def

Expand All @@ -134,8 +134,8 @@ Function Get-PSTypeExtension {
Function Get-PSType {
[cmdletbinding()]
Param(
[Parameter(Position = 0,Mandatory,ValueFromPipeline)]
[object]$Inputobject
[Parameter(Position = 0, Mandatory, ValueFromPipeline)]
[object]$Inputobject
)

Begin {
Expand All @@ -144,7 +144,7 @@ Function Get-PSType {
}
Process {
#get the type of each pipelined object
$data+= ($Inputobject | Get-Member | select-object -first 1).typename
$data += ($Inputobject | Get-Member | select-object -first 1).typename
}
End {
#write unique values to the pipeline
Expand Down Expand Up @@ -268,45 +268,45 @@ $(Get-Date)
Function Import-PSTypeExtension {
[CmdletBinding(SupportsShouldProcess)]
Param(
[Parameter(Mandatory,
ValueFromPipeline,
HelpMessage = "The name of the imported file. The extension must be .xml or .json")]
[ValidatePattern("\.(xml|json)$")]
[ValidateScript({Test-Path $(Convert-Path $_)})]
[string]$Path
[Parameter(Mandatory,
ValueFromPipeline,
HelpMessage = "The name of the imported file. The extension must be .xml or .json")]
[ValidatePattern("\.(xml|json)$")]
[ValidateScript( {Test-Path $(Convert-Path $_)})]
[string]$Path
)

Begin {
Write-Verbose "Starting: $($myInvocation.mycommand)"
Write-Verbose "Starting: $($myInvocation.mycommand)"
}
Process {
Write-Verbose "Importing file $(Convert-path $Path)"
if ($path -match "\.xml$") {
#xml format seems to add an extra entry
$import = Import-clixml -Path $path | Where-Object MemberType
}
else {
$import = Get-Content -path $path | ConvertFrom-Json
}

foreach ($item in $import) {
Write-Verbose "Processing $($item.MemberType) : $($item.MemberName)"
if ($item.MemberType -match "^Code") {
Write-Warning "Skipping Code related member"
}
if ($item.MemberType -match "^Script") {
Write-Verbose "Creating scriptblock from value"
$value = [scriptblock]::create($item.value)
Write-Verbose "Importing file $(Convert-path $Path)"
if ($path -match "\.xml$") {
#xml format seems to add an extra entry
$import = Import-clixml -Path $path | Where-Object MemberType
}
else {
$value = $item.Value
$import = Get-Content -path $path | ConvertFrom-Json
}
#add a custom -WhatIf message
if ($PSCmdlet.ShouldProcess($Item.typename, "Adding $($item.membertype) $($item.MemberName)")) {
#implement the change
Update-TypeData -TypeName $item.Typename -MemberType $item.MemberType -MemberName $item.MemberName -value $value -force
}
} #foreach

foreach ($item in $import) {
Write-Verbose "Processing $($item.MemberType) : $($item.MemberName)"
if ($item.MemberType -match "^Code") {
Write-Warning "Skipping Code related member"
}
if ($item.MemberType -match "^Script") {
Write-Verbose "Creating scriptblock from value"
$value = [scriptblock]::create($item.value)
}
else {
$value = $item.Value
}
#add a custom -WhatIf message
if ($PSCmdlet.ShouldProcess($Item.typename, "Adding $($item.membertype) $($item.MemberName)")) {
#implement the change
Update-TypeData -TypeName $item.Typename -MemberType $item.MemberType -MemberName $item.MemberName -value $value -force
}
} #foreach
}
End {
Write-Verbose "Ending: $($myInvocation.mycommand)"
Expand All @@ -316,18 +316,20 @@ Function Import-PSTypeExtension {

Function Add-PSTypeExtension {
[cmdletbinding(SupportsShouldProcess)]
[Alias('Set-PSTypeExtension')]

Param(
[Parameter(Position = 0, Mandatory,
ValueFromPipeline,
HelpMessage= "Enter the name of a type like system.io.fileinfo")]
ValueFromPipeline,
HelpMessage = "Enter the name of a type like system.io.fileinfo")]
[string]$TypeName,
[Parameter(Mandatory,HelpMessage="The member type")]
[ValidateSet("AliasProperty","Noteproperty","ScriptProperty","ScriptMethod")]
[Parameter(Mandatory, HelpMessage = "The member type")]
[ValidateSet("AliasProperty", "Noteproperty", "ScriptProperty", "ScriptMethod")]
[string]$MemberType,
[Parameter(Mandatory,HelpMessage="The name of your type extension")]
[Parameter(Mandatory, HelpMessage = "The name of your type extension")]
[ValidateNotNullOrEmpty()]
[string]$MemberName,
[Parameter(Mandatory,HelpMessage="The value for your type extension. Remember to enclose scriptblocks in {} and use `$this")]
[Parameter(Mandatory, HelpMessage = "The value for your type extension. Remember to enclose scriptblocks in {} and use `$this")]
[ValidateNotNullOrEmpty()]
[Object]$Value

Expand All @@ -340,7 +342,7 @@ Function Add-PSTypeExtension {
Process {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Adding $MemberType $Membername to $TypeName"
#force overwrite of existing extensions
$PSBoundParameters.Add("Force",$True)
$PSBoundParameters.Add("Force", $True)
Update-TypeData @PSBoundParameters
} #process

Expand All @@ -351,8 +353,3 @@ Function Add-PSTypeExtension {

} #close Add-MyTypeExtension


Set-Alias -name Set-PSTypeExtension -value Add-PSTypeExtension

Export-ModuleMember -Alias 'Set-PSTypeExtension' -Function 'Get-PSTypeExtension', 'Get-PSType',
'Import-PSTypeExtension','Export-PSTypeExtension','Add-PSTypeExtension'
Loading

0 comments on commit 06ddf13

Please sign in to comment.