<# FPS:CONTAINERS:ALOHA-P1:DATARESOURCES:SC_NEWKPGROUP:ACTIVE
#>
if (!(Push-NeededFor NewKPGroup)) {
# Remove a prior patch if it already exists
Remove-Item -Path Function:\NewKPGroup
} else {
# Only load the help line if a prior release is not
present, otherwise just keep whats there.
$kpShortcuts = @($kpShortcuts
(ConvertTo-DotFill $global:SCDotLen 'NewKPGroup')+"[-KPEntry [Obj], -KPGroupPath [Path] -Title [Title], -UID [UID], -EntryPwd [PWD] ]
"
(ConvertTo-DotFill $global:SCDotLen '')+"Function to update an existing KeePass Database
Group."
)
}
function NewKPGroup
{
<#
.SYNOPSIS
Function to create a new KeePass Database Entry.
.DESCRIPTION
This
function allows for the creation of KeePass Database Entries with basic properites available for specification.
.PARAMETER KeePassParentGroupPath
Specify
this parameter if you wish to only return entries form a specific folder path.
Notes:
*
Path Separator is the foward slash character '/'
.PARAMETER DatabaseProfileName
*This
Parameter is required in order to access your KeePass database.
.PARAMETER KeePassGroupName
Specify
the Name of the new KeePass Group.
.PARAMETER PassThru
Specify
to return the new group object.
.PARAMETER MasterKey
Specify
a SecureString MasterKey if
necessary to authenticat a keepass
databse.
If not
provided and the database requires one you will be prompted for it.
This
parameter was created with scripting in mind.
.PARAMETER IconName
Specify
the Name of the Icon for the Group to display in the KeePass UI.
.PARAMETER Notes
Specify
group notes
.PARAMETER Expires
Specify
if you want the KeePass Object to Expire, default is to not expire.
.PARAMETER ExpiryTime
Datetime expiration Time value.
.EXAMPLE
PS> NewKPGroup -DatabaseProfileName
TEST -KeePassParentGroupPath 'General/TestAccounts' -KeePassGroupName 'TestGroup'
This
Example Creates a Group Called 'TestGroup' in the
Group Path 'General/TestAccounts'
.INPUTS
Strings
.OUTPUTS
$null
#>
[CmdletBinding()]
param
(
[Parameter(Position = 0, Mandatory, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Alias('FullPath')]
[String] $KPGroupParentPath,
[Parameter(Position = 1, Mandatory)]
[ValidateNotNullOrEmpty()]
[String] $KPGroupName,
[Parameter(Position = 2)]
[ValidateNotNullOrEmpty()]
[string] $IconName = 'Folder',
[Parameter(Position = 3)]
[ValidateNotNullOrEmpty()]
[String] $Notes,
[Parameter(Position = 4)]
[switch] $Expires,
[Parameter(Position = 5)]
[DateTime] $ExpiryTime,
[Parameter(Position = 6, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[string] $DatabaseProfileName,
[Parameter(Position = 7)]
[Switch] $PassThru
)
begin
{
$overrideSrc, $overrideSnippet = '','' # Initialize override variables
#$overrideSrc, $overrideSnippet
= 'SC-NewKPGroup','SC-NewKPGroup'
# Use when running interactively
. (Get-ActiveFileNm -PS1 Initialize-DataResources-Locations)
. (Get-ActiveFileNm -PS1 Load-DataResources-Dependencies)
#$overrideSrc, $overrideSnippet
= '',''
. (Get-ActiveFileNm -PS1 SN-CheckKPDB)
}
process
{
$KeePassParentGroup = Get-KpGroup -KeePassConnection $KPDB -FullPath $KPGroupParentPath -Stop
$addKPGroupSplat = @{
KeePassConnection = $KPDB
GroupName = $KPGroupName
IconName = $IconName
PassThru = $PassThru
KeePassParentGroup
= $KeePassParentGroup
Notes = $Notes
}
#if($Notes){ $addKPGroupSplat.Notes = $Notes }
if(Test-Bound -ParameterName 'Expires'){ $addKPGroupSplat.Expires = $Expires }
if($ExpiryTime){ $addKPGroupSplat.ExpiryTime = $ExpiryTime }
# Add-KPGroup @addKPGroupSplat
| ConvertTo-KpPsObject -DatabaseProfileName
$DatabaseProfileName
Add-KPGroup @addKPGroupSplat
}
end
{
. (Get-ActiveFileNm -PS1 SN-CloseKP)
}
}