From f1439dc28df97b9aa184236ba74644649180bbad Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 18:48:07 +0100 Subject: [PATCH 01/29] =?UTF-8?q?Added=20Test=20Snapshot=20Verification=20?= =?UTF-8?q?cmdlet=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test-RubrikSnapshotVerification.ps1 | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Rubrik/Public/Test-RubrikSnapshotVerification.ps1 diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 new file mode 100644 index 00000000..b16be5dd --- /dev/null +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -0,0 +1,85 @@ +function Test-RubrikSnapshotVerification +{ + <# + .SYNOPSIS + Pauses an existing Rubrik SLA Domain + + .DESCRIPTION + The Pause-RubrikSLA cmdlet will pause an existing SLA Domain with specified parameters. An alias has been created for this function, Pause-RubrikSLA to allign better with the Rubrik Terminology. Note that this functionality is only available on Rubrik Cluster running 5.1 or later. + + .NOTES + Written by Jaap Brasser for community usage + Twitter: @jaap_brasser + GitHub: JaapBrasser + + .LINK + https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotvalidation + + .EXAMPLE + Test-RubrikSnapshotVerification + + This will initiate the tests + #> + + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = 'High')] + Param( + # Snapshot id value + [Parameter( + Position = 0, + ValueFromPipelineByPropertyName = $true, + Mandatory = $true )] + [ValidateNotNullOrEmpty()] + [String]$id, + # VM Name + [Parameter( + ParameterSetName='Query', + Position = 0, + ValueFromPipeline=$true, + Mandatory = $true )] + [Alias('SLA')] + [ValidateNotNullOrEmpty()] + [String]$Name, + # Rubrik server IP or FQDN + [String]$Server = $global:RubrikConnection.server, + # API version + [String]$api = $global:RubrikConnection.api + ) + + Begin { + + # The Begin section is used to perform one-time loads of data necessary to carry out the function's purpose + # If a command needs to be run with each iteration or pipeline input, place it in the Process section + + # Check to ensure that a session to the Rubrik cluster exists and load the needed header data for authentication + Test-RubrikConnection + + # API data references the name of the function + # For convenience, that name is saved here to $function + $function = $MyInvocation.MyCommand.Name + + # Retrieve all of the URI, method, body, query, result, filter, and success details for the API endpoint + Write-Verbose -Message "Gather API Data for $function" + $resources = Get-RubrikAPIData -endpoint $function + Write-Verbose -Message "Load API data for $($resources.Function)" + Write-Verbose -Message "Description: $($resources.Description)" + + } + + Process { + if ($PSCmdlet.ShouldProcess("snapshot id: '$id'", "Validating backup of 'jbrasser-win'")) { + + + + $uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id + $uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri + # Custom as paused is always true + $body = '{"isPaused": true}' + $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body + $result = Test-ReturnFormat -api $api -result $result -location $resources.Result + $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result + return $result + } + } # End of process +} # End of function \ No newline at end of file From c02e7dd70cb484d4d933b8839b2ef866321d2306 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 21:30:29 +0100 Subject: [PATCH 02/29] =?UTF-8?q?Updated=20for=20SnapshotVerification=20?= =?UTF-8?q?=F0=9F=93=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Private/Get-RubrikAPIData.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Rubrik/Private/Get-RubrikAPIData.ps1 b/Rubrik/Private/Get-RubrikAPIData.ps1 index 1cf9b3cf..dda954e7 100644 --- a/Rubrik/Private/Get-RubrikAPIData.ps1 +++ b/Rubrik/Private/Get-RubrikAPIData.ps1 @@ -3377,8 +3377,8 @@ function Get-RubrikAPIData { URI = '/api/internal/config/usersettable_volumeGroup' Method = 'Patch' Body = @{ - migrateFastVirtualDiskBuild = 'migrateFastVirtualDiskBuild' - maxFullMigrationStoragePercentage = 'maxFullMigrationStoragePercentage' + migrateFastVirtualDiskBuild = 'migrateFastVirtualDiskBuild' + maxFullMigrationStoragePercentage = 'maxFullMigrationStoragePercentage' } Query = '' Result = '' @@ -3518,6 +3518,18 @@ function Get-RubrikAPIData { Success = '202' } } + 'Test-RubrikSnapshotVerification' = @{ + '5.3' = @{ + Description = 'Verifies the validity of a snapshot' + URI = '/api/v1/backup/verify' + Method = 'Post' + Body = '' + Query = '' + Result = '' + Filter = '' + Success = '200' + } + } 'Update-RubrikVCenter' = @{ '1.0' = @{ Description = 'Refresh the metadata for the specified vCenter Server' From b665f5e46015c4c1b3f824c23f98927d6683558e Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 21:36:39 +0100 Subject: [PATCH 03/29] =?UTF-8?q?Updated=20for=20SnapshotVerification=20?= =?UTF-8?q?=F0=9F=93=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Private/Get-RubrikAPIData.ps1 | 7 ++++++- Rubrik/Rubrik.psd1 | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Rubrik/Private/Get-RubrikAPIData.ps1 b/Rubrik/Private/Get-RubrikAPIData.ps1 index dda954e7..1f6bbf1a 100644 --- a/Rubrik/Private/Get-RubrikAPIData.ps1 +++ b/Rubrik/Private/Get-RubrikAPIData.ps1 @@ -3523,7 +3523,12 @@ function Get-RubrikAPIData { Description = 'Verifies the validity of a snapshot' URI = '/api/v1/backup/verify' Method = 'Post' - Body = '' + Body = @{ + "objectId" = '' + "snapshotIdsOpt" = [System.Collections.ArrayList]@() + "locationIdOpt" = "locationIdOpt" + "shouldVerifyAfterOpt" = 'shouldVerifyAfterOpt' + } Query = '' Result = '' Filter = '' diff --git a/Rubrik/Rubrik.psd1 b/Rubrik/Rubrik.psd1 index e4cc3e6b..67059966 100644 --- a/Rubrik/Rubrik.psd1 +++ b/Rubrik/Rubrik.psd1 @@ -305,6 +305,7 @@ 'Stop-RubrikManagedVolumeSnapshot', 'Sync-RubrikAnnotation', 'Sync-RubrikTag', + 'Test-RubrikSnapshotVerification', 'Update-RubrikHost', 'Update-RubrikNutanixCluster', 'Update-RubrikVCD', From 71137d52719454efab0cd387322abeecdc7ef794 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 22:03:58 +0100 Subject: [PATCH 04/29] =?UTF-8?q?Added=20new=20private=20function=20?= =?UTF-8?q?=F0=9F=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConvertTo-UniversalZuluDateTime.ps1 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Rubrik/Private/ConvertTo-UniversalZuluDateTime.ps1 diff --git a/Rubrik/Private/ConvertTo-UniversalZuluDateTime.ps1 b/Rubrik/Private/ConvertTo-UniversalZuluDateTime.ps1 new file mode 100644 index 00000000..66de71dc --- /dev/null +++ b/Rubrik/Private/ConvertTo-UniversalZuluDateTime.ps1 @@ -0,0 +1,27 @@ +function ConvertTo-UniversalZuluDateTime { + <# + .SYNOPSIS + Converts a datetime value to a epoch millisecond timestamp + + .DESCRIPTION + Some API endpoints require the ISO 8601 notation for datetime stamps for more information about + this notation head over to Wikipedia: https://en.wikipedia.org/wiki/ISO_8601 + + .NOTES + Written by Jaap Brasser for community usage + Twitter: @jaap_brasser + GitHub: JaapBrasser + + .EXAMPLE + ConvertTo-UniversalZuluDateTime -DateTimeValue (Get-Date) + + 2021-02-04T21:03:09.000Z + #> + [CmdletBinding()] + param( + [DateTime]$DateTimeValue + ) + + $return = $DateTimeValue.ToUniversalTime().ToString('o') -replace '\.\d*Z$','.000Z' + return $return +} \ No newline at end of file From 528274956d378c6270a94f57e7a9f7cdda419f80 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 22:44:16 +0100 Subject: [PATCH 05/29] =?UTF-8?q?Added=20exception=20for=20Backup=20Verifi?= =?UTF-8?q?cation=20=F0=9F=8E=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Get-RubrikRequest.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Rubrik/Public/Get-RubrikRequest.ps1 b/Rubrik/Public/Get-RubrikRequest.ps1 index a48c3a8d..d51d6748 100644 --- a/Rubrik/Public/Get-RubrikRequest.ps1 +++ b/Rubrik/Public/Get-RubrikRequest.ps1 @@ -121,8 +121,13 @@ function Get-RubrikRequest { if ($Request) { Write-Verbose "Using uri supplied by pipeline: $($Request.links.href)" $uri = $Request.links.href + + # Fix for 5.3 + if ($uri -match 'backup_verification') { + $uri = $uri -replace 'backup_verification/request', 'backup/verify' + } } - + #We added new code that will now wait for the Rubrik Async Request to complete. Once completion has happened, we return back the request object. #region WaitForCompletion if ($WaitForCompletion) { From 0278249050934e2b8a0f5280938af5ad6ea8f1a8 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 4 Feb 2021 22:51:17 +0100 Subject: [PATCH 06/29] =?UTF-8?q?Updated=20and=20closer=20to=20being=20com?= =?UTF-8?q?plete=F0=9F=90=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test-RubrikSnapshotVerification.ps1 | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index b16be5dd..8cd92323 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -25,28 +25,34 @@ function Test-RubrikSnapshotVerification SupportsShouldProcess = $true, ConfirmImpact = 'High')] Param( - # Snapshot id value + # Object id value [Parameter( Position = 0, ValueFromPipelineByPropertyName = $true, Mandatory = $true )] + [Alias('objectId')] [ValidateNotNullOrEmpty()] [String]$id, - # VM Name - [Parameter( - ParameterSetName='Query', - Position = 0, - ValueFromPipeline=$true, - Mandatory = $true )] - [Alias('SLA')] + # Snapshot id value(s) + [Alias('snapshotIdsOpt')] [ValidateNotNullOrEmpty()] - [String]$Name, + [String[]]$SnapshotID, + # Location id value(s) + [Alias('locationIdOpt')] + [ValidateNotNullOrEmpty()] + [String]$LocationID, + # The datetime stamp to verify snapshots after + [Alias('shouldVerifyAfterOpt')] + [ValidateNotNullOrEmpty()] + [datetime]$VerifyAfter, # Rubrik server IP or FQDN [String]$Server = $global:RubrikConnection.server, # API version [String]$api = $global:RubrikConnection.api ) + + Begin { # The Begin section is used to perform one-time loads of data necessary to carry out the function's purpose @@ -64,22 +70,21 @@ function Test-RubrikSnapshotVerification $resources = Get-RubrikAPIData -endpoint $function Write-Verbose -Message "Load API data for $($resources.Function)" Write-Verbose -Message "Description: $($resources.Description)" - + } Process { - if ($PSCmdlet.ShouldProcess("snapshot id: '$id'", "Validating backup of 'jbrasser-win'")) { - + if ($VerifyAfter) { + $VerifyAfter = ConvertTo-UniversalZuluDateTime -DateTimeValue $VerifyAfter + } - - $uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id - $uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri - # Custom as paused is always true - $body = '{"isPaused": true}' - $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body - $result = Test-ReturnFormat -api $api -result $result -location $resources.Result - $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result - return $result + if ($PSCmdlet.ShouldProcess("snapshot id: '$id'", "Validating backup of '$id'")) { + $uri = New-URIString -server $Server -endpoint ($resources.URI) + $body = New-BodyString -bodykeys ($resources.Body.Keys) -parameters ((Get-Command $function).Parameters.Values) + $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body + $result = Test-ReturnFormat -api $api -result $result -location $resources.Result + $result = Set-ObjectTypeName -TypeName $resources.ObjectTName -result $result + return $result } } # End of process } # End of function \ No newline at end of file From 02b04a30fa92e37263d4c7c07659dae802a9bc03 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Mon, 8 Mar 2021 14:58:13 +0100 Subject: [PATCH 07/29] =?UTF-8?q?Changed=20Tag=20to=20error=20out=20when?= =?UTF-8?q?=20no=20match=20#722=20=F0=9F=90=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Protect-RubrikTag.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/Public/Protect-RubrikTag.ps1 b/Rubrik/Public/Protect-RubrikTag.ps1 index 20cb9d1c..9d25c083 100644 --- a/Rubrik/Public/Protect-RubrikTag.ps1 +++ b/Rubrik/Public/Protect-RubrikTag.ps1 @@ -89,7 +89,7 @@ function Protect-RubrikTag Write-Verbose -Message "Gathering a list of VMs associated with Category $Category and Tag $Tag" try { - $vmlist = Get-VM -Tag (Get-Tag -Name $Tag -Category $Category) | Get-View + $vmlist = Get-VM -Tag (Get-Tag -Name $Tag -Category $Category -ErrorAction Stop) | Get-View # This will pull out the vCenter UUID assigned to the parent vCenter Server by Rubrik # Reset switches to prevent Get-RubrikVM from picking them up (must be a better way?) $DoNotProtect = $false From fffc2927d02f682972babb4453dec4e83943205c Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Mon, 8 Mar 2021 14:59:14 +0100 Subject: [PATCH 08/29] =?UTF-8?q?Added=20changelog=20for=20#722=20?= =?UTF-8?q?=F0=9F=93=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ecd23c3..ecfd5c12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +* Fixed bug in `Protect-RubrikTag` which could accidentally apply results to all VMs, [Issue 722](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/722) * Fixed bug in `New-RubrikSLA` which could prevent correct SLA creation [Issue 706](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/706) * Fixed bug in `Get-RubrikEvent` which caused `-Status` not to filter properly [Issue 705](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/705) * Fixed documentation for `Invoke-RubrikGraphQLCall` multiline example changed to single line [Issue 685](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/685) From ca60a42736982e87d4a66ae8f4420951d528e49a Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Mon, 8 Mar 2021 16:33:05 +0100 Subject: [PATCH 09/29] =?UTF-8?q?Fixed=20spelling=20of=20help=20link=20?= =?UTF-8?q?=F0=9F=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Test-RubrikSnapshotVerification.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index 8cd92323..7f4abc96 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -13,7 +13,7 @@ function Test-RubrikSnapshotVerification GitHub: JaapBrasser .LINK - https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotvalidation + https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotverification .EXAMPLE Test-RubrikSnapshotVerification From 25178efcb69db686a177cc9c4f3191bb41fef578 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 11 Mar 2021 00:51:53 +0100 Subject: [PATCH 10/29] =?UTF-8?q?Added=20pipeline=20for=20SLAID,=20to=20si?= =?UTF-8?q?mplify=20commands=20=F0=9F=98=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/New-RubrikSnapshot.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Rubrik/Public/New-RubrikSnapshot.ps1 b/Rubrik/Public/New-RubrikSnapshot.ps1 index ad496ccb..13b8b9b8 100644 --- a/Rubrik/Public/New-RubrikSnapshot.ps1 +++ b/Rubrik/Public/New-RubrikSnapshot.ps1 @@ -50,7 +50,9 @@ function New-RubrikSnapshot [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact = 'High')] Param( # Rubrik's id of the object - [Parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true)] + [Parameter( + Mandatory = $true, + ValueFromPipelineByPropertyName = $true)] [String]$id, # The SLA Domain in Rubrik [Parameter( @@ -73,8 +75,10 @@ function New-RubrikSnapshot # SLA id value [Parameter( ParameterSetName = 'SLA_ByID', + ValueFromPipelineByPropertyName = $true, Mandatory = $true )] + [Alias('effectiveSlaDomainId')] [String]$SLAID, # Rubrik server IP or FQDN [String]$Server = $global:RubrikConnection.server, @@ -86,20 +90,20 @@ function New-RubrikSnapshot # The Begin section is used to perform one-time loads of data necessary to carry out the function's purpose # If a command needs to be run with each iteration or pipeline input, place it in the Process section - + # Check to ensure that a session to the Rubrik cluster exists and load the needed header data for authentication Test-RubrikConnection - + # API data references the name of the function # For convenience, that name is saved here to $function $function = $MyInvocation.MyCommand.Name - + # Retrieve all of the URI, method, body, query, result, filter, and success details for the API endpoint Write-Verbose -Message "Gather API Data for $function" $resources = Get-RubrikAPIData -endpoint $function Write-Verbose -Message "Load API data for $($resources.Function)" Write-Verbose -Message "Description: $($resources.Description)" - + } Process { @@ -134,7 +138,7 @@ function New-RubrikSnapshot $result = Submit-Request -uri $uri -header $Header -method $($resources.Method) -body $body $result = Test-ReturnFormat -api $api -result $result -location $resources.Result $result = Test-FilterObject -filter ($resources.Filter) -result $result - + return $result } } # End of process From f0649ee2f9dd098d296485ab1c03272319470e9a Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 11 Mar 2021 01:00:05 +0100 Subject: [PATCH 11/29] =?UTF-8?q?Warning=20message=20added=20#733=20?= =?UTF-8?q?=E2=9A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/New-RubrikMount.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Rubrik/Public/New-RubrikMount.ps1 b/Rubrik/Public/New-RubrikMount.ps1 index e1658403..fa1d51d1 100644 --- a/Rubrik/Public/New-RubrikMount.ps1 +++ b/Rubrik/Public/New-RubrikMount.ps1 @@ -83,6 +83,10 @@ function New-RubrikMount if(-not $PSBoundParameters.ContainsKey('DisableNetwork')) { $Resources.Body.Remove('disableNetwork') } if(-not $PSBoundParameters.ContainsKey('RemoveNetworkDevices')) { $Resources.Body.Remove('removeNetworkDevices') } if(-not $PSBoundParameters.ContainsKey('PowerOn')) { $Resources.Body.Remove('powerOn') } + + if ($id -match ':') { + Write-Warning -Message ('"{0}" specified as ID, the ID should be a snapshot ID not an object ID' -f $Id) + } $uri = New-URIString -server $Server -endpoint ($resources.URI) -id $id $uri = Test-QueryParam -querykeys ($resources.Query.Keys) -parameters ((Get-Command $function).Parameters.Values) -uri $uri From 8a4ff5bc0adac9485a371ace62194939fb268ad5 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 11 Mar 2021 01:22:36 +0100 Subject: [PATCH 12/29] =?UTF-8?q?Updated=20changelog=20with=20links=20to?= =?UTF-8?q?=20issues=20=F0=9F=A5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecfd5c12..5d74d0b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed -* Change the Quick Start Guide to links are pointing to working VMware pages [Issue 726](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/726) +### Added + +### Fixed + +## [5.3.0]() - 2021-03-11 + +### Changed + +* Changed the Quick Start Guide to links are pointing to working VMware pages [Issue 726](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/726) * Changed, parameter sets, `SLA_Name/SLA_ByID/SLA_Unprotected/SLA_Forever`, added to `Protect-RubrikFileset` & `New-RubrikSnapshot`, fixing [Issue 720](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/720) * Added support for `WhatIf` & `Confirm` to the `Invoke-RubrikRESTCall` cmdlet fixing [Issue 713](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/713) * Created 3 new parameter sets to `Invoke-RubrikRESTCall` : `BodyAsArray`, `BodyAsJson`, `General` fixing [Issue 711](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/711) @@ -29,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* Added better warning message for `New-RubrikMount`, now displays warning when an object ID is specified instead of snapshot ID, [Issue 732](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/732) * Added 5.3 endpoint for `Get-RubrikVolumeGroupMount`, resolving issue [Issue 729](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/729) * Added support to `Get-RubrikUser` to work around all of the API endpoint changes in CDM 5.3 as per [Issue 723](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/723) * Added new parameter, `SLAPrimaryClusterId`, to `Protect-RubrikFileset` & `New-RubrikSnapshot`, fixing [Issue 720](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/720) From 243f2ecf31c45d543441ab4f8600dc7cfe30245a Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 17:41:26 +0200 Subject: [PATCH 13/29] =?UTF-8?q?Added=20additional=20example=20as=20reque?= =?UTF-8?q?sted=20in=20#736=20=F0=9F=A7=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Invoke-RubrikGraphQLCall.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Rubrik/Public/Invoke-RubrikGraphQLCall.ps1 b/Rubrik/Public/Invoke-RubrikGraphQLCall.ps1 index a07d7c02..1313aae7 100644 --- a/Rubrik/Public/Invoke-RubrikGraphQLCall.ps1 +++ b/Rubrik/Public/Invoke-RubrikGraphQLCall.ps1 @@ -43,6 +43,11 @@ Returns all VMware VMs on the Rubrik Cluster and displays the individual objects Invoke-RubrikGraphQLCall -ReturnNode -Body '{"query":"query OrganizationSummary(\n $name: String,\n $isGlobal: Boolean,\n $sortBy: String,\n $sortOrder: String,\n $first: Int,\n $after: String,\n) {\n organizationConnection(\n name: $name,\n isGlobal: $isGlobal,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n first: $first,\n after: $after\n ) {\n nodes {\n id\n name\n isGlobal\n exclusivenessLevel\n admins {\n id\n name\n }\n envoyStatus\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"sortBy":"name","sortOrder":"asc","first":3,"name":"org","isGlobal":false}}' Returns informations on Rubrik Organizations, filtered by name in ascending order and only including organizations with 'org' in their name property. Returns the individual organization objects using the -ReturnNode parameter + +.EXAMPLE +(Invoke-RubrikGraphQLCall -Body '{"query":"query HostsWithSnappables(\n $effectiveSlaDomainId: String,\n $hostname: String,\n $operatingSystemType: String,\n $status: String,\n $primaryClusterId: String,\n $sortBy: String,\n $sortOrder: String,\n $templateId: String,\n $snappableStatus: String,\n $first: Int,\n $after: String,\n) {\n hostConnection(\n effectiveSlaDomainId: $effectiveSlaDomainId,\n hostname: $hostname,\n operatingSystemType: $operatingSystemType,\n status: $status,\n primaryClusterId: $primaryClusterId,\n sortBy: $sortBy,\n sortOrder: $sortOrder,\n templateId: $templateId,\n snappableStatus: $snappableStatus,\n first: $first,\n after: $after,\n )\n {\n nodes {\n id\n hostname\n primaryClusterId\n operatingSystem\n operatingSystemType\n status\n filesets\n {\n hostName\n operatingSystemType\n excludes\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n primaryClusterId\n hostId\n includes\n configuredSlaDomainId\n configuredSlaDomainType\n templateId\n allowBackupNetworkMounts\n exceptions\n effectiveSlaDomainName\n allowBackupHiddenFoldersInNetworkMounts\n templateName\n useWindowsVss\n isRelic\n name\n id\n isPassthrough\n enableSymlinkResolution\n enableHardlinkSupport\n pendingSlaDomain {\n objectId,\n pendingSlaDomainId,\n pendingSlaDomainName,\n isPendingSlaDomainRetentionLocked\n }\n }\n hostVfdDriverState\n volumeGroup\n {\n isPaused\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n primaryClusterId\n slaAssignment\n effectiveSlaSourceObjectId\n volumes {\n mountPoints\n isCurrentlyPresentOnSystem\n id\n size\n includeInSnapshots\n fileSystemType\n }\n effectiveSlaSourceObjectName\n hostId\n configuredSlaDomainId\n configuredSlaDomainType\n effectiveSlaDomainName\n hostname\n isRelic\n name\n volumeIdsIncludedInSnapshots\n id\n }\n storageArrayVolumeGroups\n {\n id\n name\n storageArrayId\n storageArrayName\n storageArrayType\n hostId\n hostname\n proxyHostId\n proxyHostname\n volumes {\n id\n serial\n name\n storageArrayId\n storageArrayType\n }\n configuredSlaDomainId\n configuredSlaDomainType\n configuredSlaDomainName\n effectiveSlaDomainId\n isEffectiveSlaDomainRetentionLocked\n effectiveSlaDomainName\n slaAssignment\n primaryClusterId\n }\n },\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n","variables":{"first":50,"operatingSystemType":"Windows","primaryClusterId":"local","sortBy":"hostname","sortOrder":"asc","snappableStatus":"Protectable"}}').hostconnection.nodes | % {[pscustomobject]@{hostname=$_.Hostname;volumegroup=$_.volumegroup.name;volumegroupsla=$_.volumegroup.effectivesladomainname}} + +Queries all hosts with volumegroups for the SLA set on that specific volumegroup. Returns 3 properties: hostname, volumegroup, volumegroupsla #> [cmdletbinding()] From 8c5d0031ec249e3b4da6e7e6e30eb05c59812742 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 17:44:46 +0200 Subject: [PATCH 14/29] =?UTF-8?q?Updated=20for=20issue=20#736=20?= =?UTF-8?q?=F0=9F=90=95=E2=80=8D=F0=9F=A6=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d74d0b0..e552525a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -## [5.3.0]() - 2021-03-11 +## [5.3.0]() - 2021-04-08 ### Changed @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* Added example in documentation for: `Invoke-RubrikGraphQLCall` [Issue 736](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/736) * Added better warning message for `New-RubrikMount`, now displays warning when an object ID is specified instead of snapshot ID, [Issue 732](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/732) * Added 5.3 endpoint for `Get-RubrikVolumeGroupMount`, resolving issue [Issue 729](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/729) * Added support to `Get-RubrikUser` to work around all of the API endpoint changes in CDM 5.3 as per [Issue 723](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/723) From 9cd4ed8377467c5beaf27af4b52b32ec18361c71 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 19:04:41 +0200 Subject: [PATCH 15/29] =?UTF-8?q?Updated=20Get-RubrikRequest=20for=20#733?= =?UTF-8?q?=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Get-RubrikRequest.ps1 | 9 ++++-- .../Test-RubrikSnapshotVerification.ps1 | 30 +++++++++---------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Rubrik/Public/Get-RubrikRequest.ps1 b/Rubrik/Public/Get-RubrikRequest.ps1 index d51d6748..6df25425 100644 --- a/Rubrik/Public/Get-RubrikRequest.ps1 +++ b/Rubrik/Public/Get-RubrikRequest.ps1 @@ -55,7 +55,8 @@ function Get-RubrikRequest { 'fileset', 'mssql', 'vmware/vm', 'hyperv/vm', 'hyperv/scvmm', 'managed_volume', 'volume_group', 'nutanix/vm', 'aws/ec2_instance', 'oracle','vcd/vapp', 'vcd/cluster', 'vmware/vcenter', 'cloud_on/azure', - 'report', 'nutanix/cluster', 'vmware/compute_cluster', 'sla_domain' + 'report', 'nutanix/cluster', 'vmware/compute_cluster', 'sla_domain', + 'backup/verify' )] [String]$Type, # Request @@ -111,6 +112,8 @@ function Get-RubrikRequest { $uri = $uri -replace 'v1', 'internal' } elseif ($v2types -contains $Type) { $uri = $uri -replace 'v1', 'v2' + } elseif ($Type -eq 'backup/verify') { + $uri = $uri -replace 'request/' } #endregion @@ -143,7 +146,9 @@ function Get-RubrikRequest { else { Write-Progress -Activity "$($result.id)" -status "Job Queued" -percentComplete (0) } - Start-Sleep -Seconds 5 + if ($result.status -notin $ExitList) { + Start-Sleep -Seconds 5 + } } while ($result.status -notin $ExitList) } #endregion diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index 7f4abc96..25eef9c2 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -1,29 +1,29 @@ function Test-RubrikSnapshotVerification { <# - .SYNOPSIS - Pauses an existing Rubrik SLA Domain + .SYNOPSIS + Tests a snapshot or multiple snapshots for consistency - .DESCRIPTION - The Pause-RubrikSLA cmdlet will pause an existing SLA Domain with specified parameters. An alias has been created for this function, Pause-RubrikSLA to allign better with the Rubrik Terminology. Note that this functionality is only available on Rubrik Cluster running 5.1 or later. + .DESCRIPTION + The Test-RubrikSnapshotVerification - .NOTES - Written by Jaap Brasser for community usage - Twitter: @jaap_brasser - GitHub: JaapBrasser + .NOTES + Written by Jaap Brasser for community usage + Twitter: @jaap_brasser + GitHub: JaapBrasser - .LINK - https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotverification + .LINK + https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotverification - .EXAMPLE - Test-RubrikSnapshotVerification + .EXAMPLE + Test-RubrikSnapshotVerification - This will initiate the tests + This will initiate the tests #> [CmdletBinding( - SupportsShouldProcess = $true, - ConfirmImpact = 'High')] + SupportsShouldProcess = $true + )] Param( # Object id value [Parameter( From ec691b3e059c8dff945ba491d12610c29c76d11e Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 19:30:35 +0200 Subject: [PATCH 16/29] =?UTF-8?q?Updated=20cmdlet=20with=20functional=20ex?= =?UTF-8?q?ample=20=F0=9F=91=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test-RubrikSnapshotVerification.ps1 | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index 25eef9c2..d044be67 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -5,7 +5,7 @@ function Test-RubrikSnapshotVerification Tests a snapshot or multiple snapshots for consistency .DESCRIPTION - The Test-RubrikSnapshotVerification + The Test-RubrikSnapshotVerification cmdlet can be used to validate the .NOTES Written by Jaap Brasser for community usage @@ -16,9 +16,24 @@ function Test-RubrikSnapshotVerification https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/test-rubriksnapshotverification .EXAMPLE - Test-RubrikSnapshotVerification + Test-RubrikSnapshotVerification -id 'VirtualMachine:::111' - This will initiate the tests + This will initiate the test for all snapshots on VM with id 111. A callback uri is returned and an ID in order to track the request + + .EXAMPLE + Get-RubrikVM jaapslilvm | Test-RubrikSnapshotVerification + + This will initiate the test for all snapshots on VM 'jaapslilvm', A callback uri is returned and an ID in order to track the request + + .EXAMPLE + Start-RubrikDownload -uri (Test-RubrikSnapshotVerification -id 'VirtualMachine:::111' | Get-RubrikRequest -WaitForCompletion).links[1].href + + This will initiate the test for all snapshots on VM with id 111. The cmdlet will then wait for the Snapshot verification to be completed, when this happens the file is stored to the current folder + + .EXAMPLE + Invoke-RestMethod -uri (Test-RubrikSnapshotVerification -id 'VirtualMachine:::111' | Get-RubrikRequest -WaitForCompletion).links[1].href | ConvertFrom-Csv + + This will initiate the test for all snapshots on VM with id 111. The cmdlet will then wait for the Snapshot verification to be completed, when this happens the results are converted from csv and displayed in the console #> [CmdletBinding( From 2ae3eaf35556e4e2b7b77d0a824ee3d70fad7374 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 19:32:17 +0200 Subject: [PATCH 17/29] =?UTF-8?q?Initialized=20tests=20for=20Snapshot=20ve?= =?UTF-8?q?r=20=F0=9F=86=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test-RubrikSnapshotVerification.Tests.ps1 | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Tests/Test-RubrikSnapshotVerification.Tests.ps1 diff --git a/Tests/Test-RubrikSnapshotVerification.Tests.ps1 b/Tests/Test-RubrikSnapshotVerification.Tests.ps1 new file mode 100644 index 00000000..c8bb8a1f --- /dev/null +++ b/Tests/Test-RubrikSnapshotVerification.Tests.ps1 @@ -0,0 +1,43 @@ +Remove-Module -Name 'Rubrik' -ErrorAction 'SilentlyContinue' +Import-Module -Name './Rubrik/Rubrik.psd1' -Force + +foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' | Where-Object extension -eq '.ps1').FullName ) { + . $privateFunctionFilePath +} + +Describe -Name 'Public/Start-RubrikManagedVolumeSnapshot' -Tag 'Public', 'Start-RubrikManagedVolumeSnapshot' -Fixture { + #region init + $global:rubrikConnection = @{ + id = 'test-id' + userId = 'test-userId' + token = 'test-token' + server = 'test-server' + header = @{ 'Authorization' = 'Bearer test-authorization' } + time = (Get-Date) + api = 'v1' + version = '4.0.5' + } + #endregion + + Context -Name 'Parameter Validation' { + Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith {} + Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { + @{ + 'snapshotId' = '11111a' + } + } + It -Name 'Request Fulfilled' -Test { + (Start-RubrikManagedVolumeSnapshot -id 'ManagedVolume:::11111' ).snapshotId | + Should -BeExactly '11111a' + } + + It -Name 'Parameter ID must be present' -Test { + { Start-RubrikManagedVolumeSnapshot -Id } | + Should -Throw "Missing an argument for parameter 'id'. Specify a parameter of type 'System.String' and try again." + } + + Assert-VerifiableMock + Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Times 1 + Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Times 1 + } +} \ No newline at end of file From 85beec3e1e5b106d648c4d22779c1a9843828441 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 21:29:27 +0200 Subject: [PATCH 18/29] =?UTF-8?q?Jaapsvm=20=F0=9F=96=96=E2=93=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Test-RubrikSnapshotVerification.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index d044be67..ae05fea0 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -21,9 +21,9 @@ function Test-RubrikSnapshotVerification This will initiate the test for all snapshots on VM with id 111. A callback uri is returned and an ID in order to track the request .EXAMPLE - Get-RubrikVM jaapslilvm | Test-RubrikSnapshotVerification + Get-RubrikVM jaapsvm | Test-RubrikSnapshotVerification - This will initiate the test for all snapshots on VM 'jaapslilvm', A callback uri is returned and an ID in order to track the request + This will initiate the test for all snapshots on VM 'jaapsvm', A callback uri is returned and an ID in order to track the request .EXAMPLE Start-RubrikDownload -uri (Test-RubrikSnapshotVerification -id 'VirtualMachine:::111' | Get-RubrikRequest -WaitForCompletion).links[1].href From c60f0d22aecc98990bc324864078dbbd4f97f920 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 22:02:13 +0200 Subject: [PATCH 19/29] =?UTF-8?q?Updated=20tests=20to=20do=20something=20?= =?UTF-8?q?=E2=84=A2=20#733?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test-RubrikSnapshotVerification.Tests.ps1 | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Tests/Test-RubrikSnapshotVerification.Tests.ps1 b/Tests/Test-RubrikSnapshotVerification.Tests.ps1 index c8bb8a1f..f5ae2fd5 100644 --- a/Tests/Test-RubrikSnapshotVerification.Tests.ps1 +++ b/Tests/Test-RubrikSnapshotVerification.Tests.ps1 @@ -5,7 +5,7 @@ foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' | . $privateFunctionFilePath } -Describe -Name 'Public/Start-RubrikManagedVolumeSnapshot' -Tag 'Public', 'Start-RubrikManagedVolumeSnapshot' -Fixture { +Describe -Name 'Public/Test-RubrikSnapshotVerification' -Tag 'Public', 'Test-RubrikSnapshotVerification' -Fixture { #region init $global:rubrikConnection = @{ id = 'test-id' @@ -15,7 +15,7 @@ Describe -Name 'Public/Start-RubrikManagedVolumeSnapshot' -Tag 'Public', 'Start- header = @{ 'Authorization' = 'Bearer test-authorization' } time = (Get-Date) api = 'v1' - version = '4.0.5' + version = '5.3' } #endregion @@ -23,12 +23,18 @@ Describe -Name 'Public/Start-RubrikManagedVolumeSnapshot' -Tag 'Public', 'Start- Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith {} Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { @{ - 'snapshotId' = '11111a' + 'id' = 'BACKUP_INTEGRITY_VERIFICATION_eedf871d-65d6-4595-8e25-50ff79a2cefc_d0376dc4-af94-494a-b4ea-5140812f5eb5:::0' + 'status' = 'RUNNING' + 'progress' = '0' + 'startTime' = '4/8/2021 5:13:17 PM' + 'nodeId' = 'cluster:::22222' + 'links' = 'http:; rel=self}}' + 'snapshotVerificationInfo' = '@{snapshotId=b33a8' } } - It -Name 'Request Fulfilled' -Test { - (Start-RubrikManagedVolumeSnapshot -id 'ManagedVolume:::11111' ).snapshotId | - Should -BeExactly '11111a' + It -Name 'Request Initiated' -Test { + (Test-RubrikSnapshotVerification -id 'VirtualMachine:::11111' ).snapshotVerificationInfo | + Should -BeExactly '@{snapshotId=b33a8' } It -Name 'Parameter ID must be present' -Test { @@ -37,7 +43,7 @@ Describe -Name 'Public/Start-RubrikManagedVolumeSnapshot' -Tag 'Public', 'Start- } Assert-VerifiableMock - Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Times 1 - Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Times 1 + Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 1 + Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 1 } } \ No newline at end of file From 36d04a60cc89dec98c2bc10d7cfa74f92927729a Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 22:56:47 +0200 Subject: [PATCH 20/29] =?UTF-8?q?Add=20Get-RubrikDebugInfo=20cmdlet=20#742?= =?UTF-8?q?=20=F0=9F=90=9B=F0=9F=90=9C=F0=9F=AA=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Rubrik.psd1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rubrik/Rubrik.psd1 b/Rubrik/Rubrik.psd1 index 67059966..c205a506 100644 --- a/Rubrik/Rubrik.psd1 +++ b/Rubrik/Rubrik.psd1 @@ -130,6 +130,7 @@ 'Get-RubrikDatabaseMount', 'Get-RubrikDatabaseRecoverableRange', 'Get-RubrikDatabaseRecoveryPoint', + 'Get-RubrikDebugInfo', 'Get-RubrikDNSSetting', 'Get-RubrikDownloadLink', 'Get-RubrikEmailSetting', @@ -354,7 +355,7 @@ # ReleaseNotes = '' # Prerelease string of this module - Prerelease = 'RC1' + # Prerelease = 'RC1' # Flag to indicate whether the module requires explicit user acceptance for install/update # RequireLicenseAcceptance = $false From 5e526466987a50261be34dd7d8a9485c6db42339 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 22:59:17 +0200 Subject: [PATCH 21/29] =?UTF-8?q?Added=20new=20cmdlet=20for=20debugging=20?= =?UTF-8?q?information=20#742=20=F0=9F=91=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rubrik/Public/Get-RubrikDebugInfo.ps1 | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Rubrik/Public/Get-RubrikDebugInfo.ps1 diff --git a/Rubrik/Public/Get-RubrikDebugInfo.ps1 b/Rubrik/Public/Get-RubrikDebugInfo.ps1 new file mode 100644 index 00000000..e7971255 --- /dev/null +++ b/Rubrik/Public/Get-RubrikDebugInfo.ps1 @@ -0,0 +1,62 @@ +#Requires -Version 3 +function Get-RubrikDebugInfo +{ + <# + .SYNOPSIS + Displays information about the Rubrik module and the PowerShell + + .DESCRIPTION + The Get-RubrikDebugInfo cmdlet will retrieve the version of code that is actively running on the system. It will gather essential information that can be used for quickly troubleshooting issues + + .NOTES + Written by Jaap Brasser for community usage + Twitter: @jaap_brasser + GitHub: JaapBrasser + + .LINK + https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/get-rubrikdebuginfo + + .EXAMPLE + Get-RubrikDebugInfo + + This will return information about the PowerShell version, the PowerShell client or console, and both the Rubrik cluster and Rubrik PowerShell module version numbers + #> + + [CmdletBinding()] + Param( + ) + + Process { + # Initiate Hash + $HashProps = [ordered]@{} + + # Add PSVersionTable + $PSVersionTable.Keys | ForEach-Object { + $HashProps.$_ = $PSVersionTable.$_ + } + + # Add Console Host information + $HashProps.HostConsoleName = $host.Name + $HashProps.HostConsoleVersion = $host.Version + $HashProps.HostCulture = $host.CurrentCulture + $HashProps.HostCultureUI = $host.CurrentUICulture + + # Gather Rubrik Cluster information + if ($RubrikConnection) { + $HashProps.RubrikConnection = $true + $HashProps.UserAgentString = $RubrikConnection.header.'User-Agent' + $HashProps.RubrikAuthentication = $RubrikConnection.header.authorization.split(' ')[0].SubString(0, 6) + $HashProps.RubrikClusterVersion = $RubrikConnection.version + } else { + Write-Warning "This cmdlet can gather more information if you're connected to your Rubrik Cluster" + } + + # Add module information + $HashProps.RubrikCurrentModuleVersion = (Get-Module -Name Rubrik) | ForEach-Object {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease} + $HashProps.RubrikInstalledModule = ((Get-Module -Name Rubrik -ListAvailable) | ForEach-Object {if ($_.PrivateData.PSData.Prerelease -ne $null) {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease} else {$_.version}}) -join ', ' + + # Output as object + return [pscustomobject]$HashProps + + } # End of process +} # End of function \ No newline at end of file From 0b0ec7745000fd5a072f8ddf43c11104db817304 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 23:00:46 +0200 Subject: [PATCH 22/29] =?UTF-8?q?Initial=20commit=201=EF=B8=8F=E2=83=A31?= =?UTF-8?q?=EF=B8=8F=E2=83=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tests/Get-RubrikDebugInfo.Tests.ps1 | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Tests/Get-RubrikDebugInfo.Tests.ps1 diff --git a/Tests/Get-RubrikDebugInfo.Tests.ps1 b/Tests/Get-RubrikDebugInfo.Tests.ps1 new file mode 100644 index 00000000..496f7e54 --- /dev/null +++ b/Tests/Get-RubrikDebugInfo.Tests.ps1 @@ -0,0 +1,45 @@ +Remove-Module -Name 'Rubrik' -ErrorAction 'SilentlyContinue' +Import-Module -Name './Rubrik/Rubrik.psd1' -Force + +foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' | Where-Object extension -eq '.ps1').FullName ) { + . $privateFunctionFilePath +} + +Describe -Name 'Public/Get-RubrikSnmpSetting' -Tag 'Public', 'Get-RubrikSnmpSetting' -Fixture { + #region init + $global:rubrikConnection = @{ + id = 'test-id' + userId = 'test-userId' + token = 'test-token' + server = 'test-server' + header = @{ 'Authorization' = 'Bearer test-authorization' } + time = (Get-Date) + api = 'v1' + version = '4.0.5' + } + #endregion + + Context -Name 'Returned Results' { + Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith { } + Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { + @{ + 'communityString' = 'SNMPString' + 'snmpAgentPort' = 'https' + 'isEnabled' = 'true' + 'trapRecieverConfigs' = '' + } + } + It -Name 'No parameters returns all results' -Test { + @( Get-RubrikSnmpSetting | Measure-Object).Count | + Should -BeExactly 1 + } + It -Name 'Port is https' -Test { + @( Get-RubrikSnmpSetting).snmpAgentPort | + Should -BeExactly 'https' + } + + Assert-VerifiableMock + Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 2 + Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 2 + } +} \ No newline at end of file From 662b8823a1a549876e734267a5f25bcb3d349de8 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 23:07:52 +0200 Subject: [PATCH 23/29] =?UTF-8?q?Added=20unit=20tests=20for=20#742=20?= =?UTF-8?q?=F0=9F=A7=AA=F0=9F=A6=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tests/Get-RubrikDebugInfo.Tests.ps1 | 38 ++++++++++------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/Tests/Get-RubrikDebugInfo.Tests.ps1 b/Tests/Get-RubrikDebugInfo.Tests.ps1 index 496f7e54..a14a5632 100644 --- a/Tests/Get-RubrikDebugInfo.Tests.ps1 +++ b/Tests/Get-RubrikDebugInfo.Tests.ps1 @@ -1,13 +1,9 @@ Remove-Module -Name 'Rubrik' -ErrorAction 'SilentlyContinue' Import-Module -Name './Rubrik/Rubrik.psd1' -Force -foreach ( $privateFunctionFilePath in ( Get-ChildItem -Path './Rubrik/Private' | Where-Object extension -eq '.ps1').FullName ) { - . $privateFunctionFilePath -} - -Describe -Name 'Public/Get-RubrikSnmpSetting' -Tag 'Public', 'Get-RubrikSnmpSetting' -Fixture { +Describe -Name 'Public/Get-RubrikDebugInfo' -Tag 'Public', 'Get-RubrikDebugInfo' -Fixture { #region init - $global:rubrikConnection = @{ + $rubrikConnection = @{ id = 'test-id' userId = 'test-userId' token = 'test-token' @@ -19,27 +15,19 @@ Describe -Name 'Public/Get-RubrikSnmpSetting' -Tag 'Public', 'Get-RubrikSnmpSett } #endregion - Context -Name 'Returned Results' { - Mock -CommandName Test-RubrikConnection -Verifiable -ModuleName 'Rubrik' -MockWith { } - Mock -CommandName Submit-Request -Verifiable -ModuleName 'Rubrik' -MockWith { - @{ - 'communityString' = 'SNMPString' - 'snmpAgentPort' = 'https' - 'isEnabled' = 'true' - 'trapRecieverConfigs' = '' - } - } - It -Name 'No parameters returns all results' -Test { - @( Get-RubrikSnmpSetting | Measure-Object).Count | - Should -BeExactly 1 + Context -Name 'Validate output of cmdlet' { + It -Name 'Should return correct PSVersion' -Test { + (Get-RubrikDebugInfo).PSVersion | Should -BeExactly $PSVersionTable.PSVersion } - It -Name 'Port is https' -Test { - @( Get-RubrikSnmpSetting).snmpAgentPort | - Should -BeExactly 'https' + + It -Name 'Should return correct HostConsoleVersion' -Test { + $WarningPreference = 0 + (Get-RubrikDebugInfo).HostConsoleName | Should -BeExactly $host.Name } - Assert-VerifiableMock - Assert-MockCalled -CommandName Test-RubrikConnection -ModuleName 'Rubrik' -Exactly 2 - Assert-MockCalled -CommandName Submit-Request -ModuleName 'Rubrik' -Exactly 2 + It -Name 'Should return correct Culture' -Test { + $WarningPreference = 0 + (Get-RubrikDebugInfo).HostCulture | Should -BeExactly $host.CurrentCulture + } } } \ No newline at end of file From 1b5e9339fee3588d3f6cec7e78dd3eca2eaf6b26 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 23:09:23 +0200 Subject: [PATCH 24/29] =?UTF-8?q?Updated=20for=20#742=20=F0=9F=8E=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e552525a..9db97077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +* Added new cmdlet: `Get-RubrikDebugInfo`, that gathers essential information for troubleshooting [Issue 742](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/742) * Added example in documentation for: `Invoke-RubrikGraphQLCall` [Issue 736](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/736) * Added better warning message for `New-RubrikMount`, now displays warning when an object ID is specified instead of snapshot ID, [Issue 732](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/732) * Added 5.3 endpoint for `Get-RubrikVolumeGroupMount`, resolving issue [Issue 729](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/729) From 99e39399bb98821c181cc15e687654bb47812c2b Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 23:10:50 +0200 Subject: [PATCH 25/29] =?UTF-8?q?Added=20snapshot=20validation=20#733=20?= =?UTF-8?q?=F0=9F=A6=A0=F0=9F=91=BE=F0=9F=AA=B2=F0=9F=96=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db97077..dcda4070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added * Added new cmdlet: `Get-RubrikDebugInfo`, that gathers essential information for troubleshooting [Issue 742](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/742) +* Added new cmdlet: `Test-RubrikSnapshotVerification`, that can test if a snapshot, or series of snapshots are recoverable [Issue 733](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/733) * Added example in documentation for: `Invoke-RubrikGraphQLCall` [Issue 736](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/736) * Added better warning message for `New-RubrikMount`, now displays warning when an object ID is specified instead of snapshot ID, [Issue 732](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/732) * Added 5.3 endpoint for `Get-RubrikVolumeGroupMount`, resolving issue [Issue 729](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/729) From 37fd4bdc71d0914fe1803aff7136ef33e1679528 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 8 Apr 2021 23:16:47 +0200 Subject: [PATCH 26/29] =?UTF-8?q?Fixed=20unit=20test=20for=20DebugInfo=20?= =?UTF-8?q?=F0=9F=AA=B2=F0=9F=91=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tests/Get-RubrikAPIData.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Get-RubrikAPIData.Tests.ps1 b/Tests/Get-RubrikAPIData.Tests.ps1 index 8f519ffc..2868ef33 100644 --- a/Tests/Get-RubrikAPIData.Tests.ps1 +++ b/Tests/Get-RubrikAPIData.Tests.ps1 @@ -19,7 +19,7 @@ Describe -Name 'Private/Get-RubrikAPIData' -Tag 'Private', 'Get-RubrikAPIData' - } #Function List - $ignorelist = @('Invoke-RubrikRESTCall','Invoke-RubrikGraphQLCall','Move-RubrikMountVMDK','Sync-RubrikAnnotation','Sync-RubrikTag','Get-RubrikModuleDefaultParameter','Set-RubrikModuleDefaultParameter','Get-RubrikModuleOption','Set-RubrikModuleOption','Remove-RubrikModuleDefaultParameter','Get-RubrikDownloadLink','Start-RubrikDownload') + $ignorelist = @('Invoke-RubrikRESTCall','Invoke-RubrikGraphQLCall','Move-RubrikMountVMDK','Sync-RubrikAnnotation','Sync-RubrikTag','Get-RubrikModuleDefaultParameter','Set-RubrikModuleDefaultParameter','Get-RubrikModuleOption','Set-RubrikModuleOption','Remove-RubrikModuleDefaultParameter','Get-RubrikDownloadLink','Start-RubrikDownload','Get-RubrikDebugInfo') $functions = ( Get-ChildItem -Path './Rubrik/Public' | Where-Object extension -eq '.ps1').Name.Replace('.ps1','') $functions = $functions | Where-Object {$ignorelist -notcontains $_} @@ -69,7 +69,7 @@ Describe -Name 'Private/Get-RubrikAPIData' -Tag 'Private', 'Get-RubrikAPIData' - It -Name 'Verify property exists' -Test { $functions = ( Get-ChildItem -Path './Rubrik/Public' | Where-Object extension -eq '.ps1').Name.Replace('.ps1','') - $ignorelist = @('Invoke-RubrikRESTCall','Invoke-RubrikGraphQLCall','Move-RubrikMountVMDK','Sync-RubrikAnnotation','Sync-RubrikTag','Get-RubrikObject','Get-RubrikDatabaseRecoveryPoint','Get-RubrikModuleDefaultParameter','Set-RubrikModuleDefaultParameter','Get-RubrikModuleOption','Set-RubrikModuleOption','Remove-RubrikModuleDefaultParameter', 'Get-RubrikDownloadLink','Start-RubrikDownload','Get-RubrikVgfClusterStorage','Get-RubrikVgfReport','Get-RubrikVgfUpgradeReport') + $ignorelist = @('Invoke-RubrikRESTCall','Invoke-RubrikGraphQLCall','Move-RubrikMountVMDK','Sync-RubrikAnnotation','Sync-RubrikTag','Get-RubrikObject','Get-RubrikDatabaseRecoveryPoint','Get-RubrikModuleDefaultParameter','Set-RubrikModuleDefaultParameter','Get-RubrikModuleOption','Set-RubrikModuleOption','Remove-RubrikModuleDefaultParameter', 'Get-RubrikDownloadLink','Start-RubrikDownload','Get-RubrikVgfClusterStorage','Get-RubrikVgfReport','Get-RubrikVgfUpgradeReport', 'Get-RubrikDebugInfo') $functions = $functions | Where-Object {$ignorelist -notcontains $_} $functions | ForEach-Object { (Get-RubrikAPIData -Endpoint $_).Function | From b42159e5eaf75a1c6be89e1fbf1908dbac616055 Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Fri, 9 Apr 2021 09:09:32 -0400 Subject: [PATCH 27/29] added module options and parameters --- Rubrik/Public/Get-RubrikDebugInfo.ps1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Rubrik/Public/Get-RubrikDebugInfo.ps1 b/Rubrik/Public/Get-RubrikDebugInfo.ps1 index e7971255..d03f831c 100644 --- a/Rubrik/Public/Get-RubrikDebugInfo.ps1 +++ b/Rubrik/Public/Get-RubrikDebugInfo.ps1 @@ -1,21 +1,21 @@ #Requires -Version 3 function Get-RubrikDebugInfo { - <# + <# .SYNOPSIS - Displays information about the Rubrik module and the PowerShell - + Displays information about the Rubrik module and the PowerShell + .DESCRIPTION The Get-RubrikDebugInfo cmdlet will retrieve the version of code that is actively running on the system. It will gather essential information that can be used for quickly troubleshooting issues - + .NOTES Written by Jaap Brasser for community usage Twitter: @jaap_brasser GitHub: JaapBrasser - + .LINK https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/get-rubrikdebuginfo - + .EXAMPLE Get-RubrikDebugInfo @@ -55,6 +55,10 @@ function Get-RubrikDebugInfo $HashProps.RubrikCurrentModuleVersion = (Get-Module -Name Rubrik) | ForEach-Object {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease} $HashProps.RubrikInstalledModule = ((Get-Module -Name Rubrik -ListAvailable) | ForEach-Object {if ($_.PrivateData.PSData.Prerelease -ne $null) {'{0}-{1}' -f $_.Version,$_.PrivateData.PSData.Prerelease} else {$_.version}}) -join ', ' + # Add configured module options and default parameters + $HashProps.RubrikModuleOptions = Get-RubrikModuleOption + $HashProps.RubrikModuleDefaultParameters = Get-RubrikModuleDefaultParameter + # Output as object return [pscustomobject]$HashProps From a09ec0e2f3ca944e05fb9fcc97d521d8ed301746 Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Fri, 9 Apr 2021 09:21:02 -0400 Subject: [PATCH 28/29] fixed description --- Rubrik/Public/Test-RubrikSnapshotVerification.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index ae05fea0..357246f7 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -1,11 +1,11 @@ function Test-RubrikSnapshotVerification { - <# + <# .SYNOPSIS Tests a snapshot or multiple snapshots for consistency .DESCRIPTION - The Test-RubrikSnapshotVerification cmdlet can be used to validate the + The Test-RubrikSnapshotVerification cmdlet can be used to validate the fingerprint of a snapshot(s) for consistency and reliablity. .NOTES Written by Jaap Brasser for community usage @@ -66,26 +66,26 @@ function Test-RubrikSnapshotVerification [String]$api = $global:RubrikConnection.api ) - + Begin { # The Begin section is used to perform one-time loads of data necessary to carry out the function's purpose # If a command needs to be run with each iteration or pipeline input, place it in the Process section - + # Check to ensure that a session to the Rubrik cluster exists and load the needed header data for authentication Test-RubrikConnection - + # API data references the name of the function # For convenience, that name is saved here to $function $function = $MyInvocation.MyCommand.Name - + # Retrieve all of the URI, method, body, query, result, filter, and success details for the API endpoint Write-Verbose -Message "Gather API Data for $function" $resources = Get-RubrikAPIData -endpoint $function Write-Verbose -Message "Load API data for $($resources.Function)" Write-Verbose -Message "Description: $($resources.Description)" - + } Process { From bb7e33a7567f3db541a50a752123ae154130b3e7 Mon Sep 17 00:00:00 2001 From: Mike Preston Date: Fri, 9 Apr 2021 09:21:46 -0400 Subject: [PATCH 29/29] fixed description --- Rubrik/Public/Test-RubrikSnapshotVerification.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 index 357246f7..ba5b32c8 100644 --- a/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 +++ b/Rubrik/Public/Test-RubrikSnapshotVerification.ps1 @@ -5,7 +5,7 @@ function Test-RubrikSnapshotVerification Tests a snapshot or multiple snapshots for consistency .DESCRIPTION - The Test-RubrikSnapshotVerification cmdlet can be used to validate the fingerprint of a snapshot(s) for consistency and reliablity. + The Test-RubrikSnapshotVerification cmdlet can be used to validate the fingerprint of a snapshot(s) for consistency and reliablity, returning a csv containing the results .NOTES Written by Jaap Brasser for community usage