Skip to content

Commit

Permalink
Merge pull request #74 from fscpscollaborative/develop
Browse files Browse the repository at this point in the history
Merges develop to master
  • Loading branch information
onikolaiev authored Dec 30, 2024
2 parents f4365c1 + 20a4dc8 commit e1cd7eb
Show file tree
Hide file tree
Showing 27 changed files with 662 additions and 58 deletions.
135 changes: 135 additions & 0 deletions docs/Update-FSCPSNugetsFromLCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
external help file: fscps.tools-help.xml
Module Name: fscps.tools
online version:
schema: 2.0.0
---

# Update-FSCPSNugetsFromLCS

## SYNOPSIS
This uploads the D365FSC nugets from the LCS to the active storage account

## SYNTAX

```
Update-FSCPSNugetsFromLCS [[-LCSUserName] <String>] [[-LCSUserPassword] <SecureString>]
[[-LCSProjectId] <String>] [[-LCSClientId] <String>] [[-FSCMinimumVersion] <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
This uploads the D365FSC nugets from the LCS to the active NuGet storage account

## EXAMPLES

### EXAMPLE 1
```
Update-FSCPSNugetsFromLCS -LCSUserName "[email protected]" -LCSUserPassword "superSecureString" -LCSProjectId "123456" -LCSClientId "123ebf68-a86d-4392-ae38-57b2172ee789" -FSCMinimumVersion "10.0.38"
```

this will uploads the D365FSC nugets from the LCS to the active storage account

## PARAMETERS

### -LCSUserName
The LCS username

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LCSUserPassword
The LCS password
```yaml
Type: SecureString
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LCSProjectId
The LCS project ID
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LCSClientId
The ClientId what has access to the LCS
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FSCMinimumVersion
The minimum version of the FSC to update the NuGet\`s
```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
Author: Oleksandr Nikolaiev (@onikolaiev)
## RELATED LINKS
8 changes: 4 additions & 4 deletions fscps.tools/fscps.tools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Oleksandr Nikolaiev
#
# Generated on: 7/15/2024
# Generated on: 12/30/2024
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'fscps.tools.psm1'

# Version number of this module.
ModuleVersion = '1.0.263'
ModuleVersion = '1.0.274'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -27,7 +27,7 @@ Author = 'Oleksandr Nikolaiev'
CompanyName = 'Ciellos Inc.'

# Copyright statement for this module
Copyright = 'Copyright (c) 2024 Oleksandr Nikolaiev. All rights reserved.'
Copyright = 'Copyright (c) 2025 Oleksandr Nikolaiev. All rights reserved.'

# Description of the functionality provided by this module
Description = 'fscps.tools'
Expand Down Expand Up @@ -84,7 +84,7 @@ FunctionsToExport = 'Get-FSCPSSettings', 'Set-FSCPSSettings', 'Invoke-FSCPSChoco
'Set-FSCPSActiveAzureStorageConfig',
'Invoke-FSCPSAzureStorageDownload',
'Invoke-FSCPSAzureStorageUpload', 'Invoke-FSCPSAzureStorageDelete',
'Update-FSCPSISVSource'
'Update-FSCPSISVSource', 'Update-FSCPSNugetsFromLCS'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down
60 changes: 42 additions & 18 deletions fscps.tools/functions/get-fscpsazurestoragefile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,77 @@
The SAS key that you have created for the storage account or blob container
.PARAMETER DestinationPath
The destination folder of the Azure file to download. If enpty just show the info
The destination folder of the Azure file to download. If empty just show the file information
.PARAMETER Container
Name of the blob container inside the storage account you want to look for files
Name of the blob container inside the storage account where you want to look for files
.PARAMETER Name
Name of the file you are looking for
Accepts wildcards for searching. E.g. -Name "Application*Adaptor"
Default value is "*" which will search for all packages
Default value is "*" which will search for all files
.PARAMETER Latest
Instruct the cmdlet to only fetch the latest file from the Azure Storage Account
Latest nugets parameter
.EXAMPLE
PS C:\> Get-FSCPSAzureStorageFile -AccountId "miscfiles" -AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" -Container "backupfiles"
This will get all files in the blob container "backupfiles".
This will get the information of all files in the blob container "backupfiles".
It will use the AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" to gain access.
.EXAMPLE
PS C:\> Get-FSCPSAzureStorageFile -AccountId "miscfiles" -AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" -Container "backupfiles" -Latest
This will get the latest (newest) file from the blob container "backupfiles".
This will get the information of the latest (newest) file from the blob container "backupfiles".
It will use the AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" to gain access to the container.
.EXAMPLE
PS C:\> Get-FSCPSAzureStorageFile -AccountId "miscfiles" -AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" -Container "backupfiles" -Name "*UAT*"
This will get all files in the blob container "backupfiles" that fits the "*UAT*" search value.
This will get the information of all files in the blob container "backupfiles" that fits the "*UAT*" search value.
It will use the AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" to gain access to the container.
.EXAMPLE
PS C:\> Get-FSCPSAzureStorageFile -AccountId "miscfiles" -SAS "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk" -Container "backupfiles" -Latest
This will get the latest (newest) file from the blob container "backupfiles".
This will get the information of the latest (newest) file from the blob container "backupfiles".
It will use the SAS key "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk" to gain access to the container.
.EXAMPLE
PS C:\> Get-FSCPSAzureStorageFile -AccountId "miscfiles" -SAS "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk" -Container "backupfiles" -Name "*UAT*" -DestinationPath "C:\Temp"
This will get the information of all files in the blob container "backupfiles" that fits the "*UAT*" search value.
It will also download all the files to the "C:\Temp" folder.
It will use the SAS key "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk" to gain access to the container.
.NOTES
Tags: Azure, Azure Storage, Token, Blob, File, Container
This is refactored function from d365fo.tools
This is refactored function from d365fo.tools (https://github.com/d365collaborative/d365fo.tools) under the
MIT License
Copyright (c) 2018 Mötz Jensen & Rasmus Andersen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original Author: Mötz Jensen (@Splaxi)
Author: Oleksandr Nikolaiev (@onikolaiev)
Expand Down Expand Up @@ -113,26 +139,24 @@ function Get-FSCPSAzureStorageFile {
}

try {
$files = Get-AzStorageBlob -Container $($Container.ToLower()) -Context $storageContext | Sort-Object -Descending { $_.Properties.LastModified }
$files = Get-AzStorageBlob -Container $($Container.ToLower()) -Context $storageContext | Sort-Object -Descending { $_.LastModified }

if ($Latest) {
$files | Select-Object -First 1 | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "LastModified"; Expression = { [Datetime]::Parse($_.LastModified) } }
$files | Select-Object -First 1 | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "LastModified"; Expression = { $_.LastModified.UtcDateTime } }
}
else {

foreach ($obj in $files) {
if ($obj.Name -NotLike $Name) { continue }

if($DestinationPath)
{
if ($DestinationPath) {
$null = Test-PathExists -Path $DestinationPath -Type Container -Create
$destinationBlobPath = (Join-Path $DestinationPath ($obj.Name))
Get-AzStorageBlobContent -Context $storageContext -Container $($Container.ToLower()) -Blob $obj.Name -Destination ($destinationBlobPath) -ConcurrentTaskCount 10 -Force
$obj | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "Path"; Expression = { [string]$destinationBlobPath } }, @{Name = "LastModified"; Expression = { [Datetime]::Parse($_.LastModified) } }
$obj | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "Path"; Expression = { [string]$destinationBlobPath } }, @{Name = "LastModified"; Expression = { $_.LastModified.UtcDateTime } }
}
else
{
$obj | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "LastModified"; Expression = { [Datetime]::Parse($_.LastModified) } }
else {
$obj | Select-PSFObject -TypeName FSCPS.TOOLS.Azure.Blob "name", @{Name = "Size"; Expression = { [PSFSize]$_.Length } }, @{Name = "LastModified"; Expression = { $_.LastModified.UtcDateTime } }
}


Expand Down
Loading

0 comments on commit e1cd7eb

Please sign in to comment.