Close-BcpPackage

Closes an open BCP package.

Syntax

Close-BcpPackage [[-Path] <DirectoryInfo>] [<CommonParameters>]

Parameters

Type

Name

Description

Default value

Optional

DirectoryInfo

Path

Directory of the opened BCP package that should get closed

The last opened BCP package

yes

Return type

Bool: on success the cmdlet returns $true otherwise $false.
$result.Error ← On failure with an additional property ‘Error’ containing the Exception
$result.Location ← The directory where the closed BCP package is located
$result.DatabaseLocation ← The location of the internal Database-file of the closed BCP package

Remarks

The cmdlet closes the previously opened BCP package within the current AppDomain.
When multiple BCP packages are opened simultaneously the Path to the desired BCP package can be specified.

After closing a BCP package ongoing operations will not use the closed package any more.
Memory resourses and locks to the internal Database-file become automatically released.

Examples

In the following examples we are using our VaultBcp 2024 sample package for demonstration purposes:
Closing the previously opened BCP package

Open-BcpPackage -Path 'C:\Temp\bcp_samplepackage' -IgnoreBomBlobs
#...
Close-BcpPackage

Closing one of several opened BCP packages

Open-BcpPackage -Path 'C:\Temp\bcp_samplepackage' -IgnoreBomBlobs
Open-BcpPackage -Path '.\bcp_customerpackage'
Close-BcpPackage -Path 'C:\Temp\bcp_samplepackage'

Validating if the BCP package got closed correctly

$closePackageResult = Close-BcpPackage
if(-not $closePackageResult ) {
	throw "Failed with error: " + $closePackageResult.Error.Message
}

Closing a BCP package and using the close result

$openPackageResult = Open-BcpPackage -Path 'C:\Temp\bcp_samplepackage' -IgnoreBomBlobs

$closePackageResult = $openPackageResult.Location | Close-BcpPackage

write-host "Closed package '$($closePackageResult.Location.Fullname)'..."
write-host "Version: '$([int]$closePackageResult.Version)'"
write-host "Internal database: '$($closePackageResult.DatabaseLocation.Name)'"