From d8cdab324f4e667c1b1e533c0c2b419a72c0c440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Gonz=C3=A1lez?= Date: Wed, 24 May 2023 08:07:38 +0000 Subject: [PATCH] Add-MyMember --- Docs.psm1 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Docs.psm1 b/Docs.psm1 index ed9f124..c0b989f 100755 --- a/Docs.psm1 +++ b/Docs.psm1 @@ -810,7 +810,7 @@ function global:Get-DocsName{ } function global:Get-DocsNameSample{ - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding()] param( [parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)][Alias("PSPath")][string[]]$Path, [parameter(ValueFromPipelineByPropertyName)][string]$Date, @@ -1146,4 +1146,23 @@ function Format-DocsName { $input | ForEach-Object { $_.Name() } } # Export-ModuleMember -Function Format-DocsName -Alias "fname" -#endregion Formats \ No newline at end of file +#endregion Formats + +#region utils + +function Add-MyMember{ + [CmdletBinding()] + param( + [parameter(Mandatory,ValueFromPipeline)][Object] $object, + [parameter(Mandatory)][string]$NotePropertyName, + [parameter(Mandatory)][string]$NotePropertyValue + ) + + if ($Object.$NotePropertyName) { + $Object.$NotePropertyName = $NotePropertyValue + } else { + $object | Add-Member -NotePropertyName $NotePropertyName -NotePropertyValue $NotePropertyValue + } +} + +#endregion utils \ No newline at end of file