ObjectHandling/Export-ObjectsToFolder.ps1
function Export-ObjectsToFolder { Param( [Parameter(Mandatory=$false)] [string] $ContainerName, [Parameter(Mandatory=$true)] [string] $Folder, [Parameter(Mandatory=$false)] [pscredential] $Credential ) if ($null -eq $ContainerName -or $ContainerName -eq "") { $ContainerName = (Get-EnvironmentKeyValue -KeyName 'name') } if ($null -eq $Credential) { $NewCredential = New-CredentialFromEnvironmentJson if ($NewCredential -eq $false) { $Credential = [PSCredential]::new('admin', (ConvertTo-SecureString 'P@ssword1' -AsPlainText -Force)) } else { $Credential = $NewCredential } } if (!(Test-Path $Folder -PathType Container)) { New-Item $Folder -ItemType Directory -Force } $containerFolder = ((Get-NavContainerSharedFolders $ContainerName).GetEnumerator() | Where-Object { $_.Value -eq "C:\Run\my"}).Name $objectsFilter = (Get-EnvironmentKeyValue -KeyName 'objectsFilter') if (($null -eq $objectsFilter) -or ($objectsFilter -eq '')) { return } $objectsName = ("{0}_{1}_{2}_BaseObjects.fob" -f (Get-AppKeyValue -KeyName 'publisher'), (Get-AppKeyValue -KeyName 'name'), (Get-AppKeyValue -KeyName 'version')) Export-NavContainerObjects -containerName $ContainerName -objectsFolder "$containerFolder" -filter "$objectsFilter" -sqlCredential $Credential -exportTo 'fob file' if (Test-Path (Join-Path $containerFolder "objects.fob") -PathType Leaf) { Copy-Item -Path (Join-Path $containerFolder "objects.fob") -Destination (Join-Path $Folder $objectsName) -Force Remove-Item (Join-Path $containerFolder "objects.fob") -Force } } Export-ModuleMember Export-ObjectsToFolder |