Skip to content

Commit 986651a

Browse files
authored
Merge pull request #769 from rubrikinc/jaap-unicode
Fixed unicode issues with cmdlets
2 parents 4b450c7 + 82d7733 commit 986651a

25 files changed

+3410
-198
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
* **Fixed** for any bug fixes.
1515
* **Security** in case of vulnerabilities.
1616

17-
## Unreleased
17+
## [5.3.1](https://github.com/rubrikinc/rubrik-sdk-for-powershell/tree/5.3.1) - 2021-07-06
1818

1919
### Changed
2020

@@ -23,10 +23,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323

2424
### Added
2525

26+
* Added troubleshooting step and additional CDM API links, resolving [Issue 770](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/770)
27+
* Added additional debug logging to `Invoke-RubrikWebRequest`, resolving [Issue 721](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/721)
28+
2629
### Fixed
2730

28-
* Fixed documentation for `New-RubrikHyperVVMMount` resolving [Issue 756](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/756)
31+
* Fixed typo in documentation, resolving [Issue 776](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/776)
32+
* Fixed Unicode issues for all cmdlets, resolving [Issue 768](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/768), [Issue 750](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/750), [Issue 749](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/749)
2933
* Fixed documentation for `Sync-RubrikTag`, resolving [Issue 757](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/757)
34+
* Fixed documentation for `New-RubrikHyperVVMMount` resolving [Issue 756](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/756)
3035
* Updated API endpoints to `v1` for `Get-RubrikHostVolume`, `New-RubrikSnapshot` (VolumeGroup endpoint) & `Protect-RubrikVolumeGroup` cmdlets, fixing [Issue 747](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/747)
3136
* Fixed bug in `Submit-Request` which causes several issues [Issue 751](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/751) & [Issue 752](https://github.com/rubrikinc/rubrik-sdk-for-powershell/issues/752)
3237

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Rubrik SDK for PowerShell
22

3-
[![Build Status](https://dev.azure.com/rubrik-build/rubrik-sdk-for-powershell/_apis/build/status/rubrikinc.rubrik-sdk-for-powershell?branchName=devel)](https://dev.azure.com/rubrik-build/rubrik-sdk-for-powershell/_build/latest?definitionId=3&branchName=devel)
4-
[![Build Status](https://dev.azure.com/rubrik-build/rubrik-sdk-for-powershell/_apis/build/status/rubrikinc.rubrik-sdk-for-powershell?branchName=master)](https://dev.azure.com/rubrik-build/rubrik-sdk-for-powershell/_build/latest?definitionId=3&branchName=master)
5-
63
This is a community project that provides a Microsoft PowerShell module for managing and monitoring Rubrik's Multi-Cloud Data Control fabric by way of published RESTful APIs. If you're looking to perform interactive automation, setting up scheduled tasks, leverage an orchestration engine, or need ad-hoc operations, this module is intended to be valuable to your needs.
74

85
# :hammer: Installation
@@ -13,9 +10,9 @@ Load the module by using:
1310

1411
If you wish to load a specific version, use:
1512

16-
`Import-Module Rubrik -RequiredVersion #.#.#.#`
13+
`Import-Module Rubrik -RequiredVersion #.#.#`
1714

18-
Where `#.#.#.#` represents the version number.
15+
Where `#.#.#` represents the version number, for example 5.3.1
1916

2017
# :mag: Example
2118

Rubrik/Private/Invoke-RubrikWebRequest.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ function Invoke-RubrikWebRequest {
1717
# Write Debug information
1818
Write-Debug -Message ($PSBoundParameters.GetEnumerator()|Out-String)
1919

20+
if (Test-UnicodeInString -String $Body) {
21+
$PSBoundParameters.Add('ContentType', 'text/plain; charset=utf-8')
22+
Write-Verbose -Message ('Submitting "{0}" request as "text/plain; charset=utf-8"' -f $Method)
23+
}
24+
2025
if (Test-PowerShellSix) {
2126
if (-not [string]::IsNullOrWhiteSpace($rubrikOptions.ModuleOption.DefaultWebRequestTimeOut) -or $rubrikOptions.ModuleOption.DefaultWebRequestTimeOut -gt 99) {
2227
Write-Verbose -Message "Invoking request with a custom timeout of $($rubrikOptions.ModuleOption.DefaultWebRequestTimeOut) seconds"
@@ -36,6 +41,7 @@ function Invoke-RubrikWebRequest {
3641
}
3742

3843
Write-Verbose -Message "Received HTTP Status $($result.StatusCode)"
44+
Write-Debug -Message "Raw Response content:`n $($result.rawcontent)"
3945

4046
return $result
4147
}

Rubrik/Private/Submit-Request.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,22 @@ function Submit-Request {
3636
if (Test-PowerShellSix) {
3737
# Uses the improved ConvertFrom-Json cmdlet as provided in PowerShell 6.1
3838
# In the case of DELETE, there is no content (json body) to parse.
39-
$result = if ($null -ne ($WebResult = Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body)) {
40-
if ($null -ne $WebResult.Content) {
39+
$result = if (($WebResult = Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body)) {
40+
if ($WebResult.Content) {
4141
ConvertFrom-Json -InputObject $WebResult.Content
4242
}
4343
}
4444
} else {
4545
# Because some calls require more than the default payload limit of 2MB, ExpandPayload dynamically adjusts the payload limit
46-
$result = ExpandPayload -response ($WebResult = Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body)
46+
$WebResult = Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body
47+
if (Test-UnicodeInString -String $WebResult.Content) {
48+
$WebResult = [pscustomobject]@{
49+
Content = [system.Text.Encoding]::UTF8.GetString($WebResult.RawContentStream.ToArray())
50+
StatusCode = $WebResult.StatusCode
51+
StatusDescription = $WebResult.StatusDescription
52+
}
53+
}
54+
$result = ExpandPayload -response $WebResult
4755
}
4856
# If $result is null, build a $result object to return to the user. Otherwise, $result will be returned.
4957
if ($null -eq $result) {
@@ -71,7 +79,15 @@ function Submit-Request {
7179
$result = ConvertFrom-Json -InputObject (Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body).Content
7280
} else {
7381
# Because some calls require more than the default payload limit of 2MB, ExpandPayload dynamically adjusts the payload limit
74-
$result = ExpandPayload -response (Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body)
82+
$WebResult = Invoke-RubrikWebRequest -Uri $uri -Headers $header -Method $method -Body $body
83+
if (Test-UnicodeInString -String $WebResult.Content) {
84+
$WebResult = [pscustomobject]@{
85+
Content = [system.Text.Encoding]::UTF8.GetString($WebResult.RawContentStream.ToArray())
86+
StatusCode = $WebResult.StatusCode
87+
StatusDescription = $WebResult.StatusDescription
88+
}
89+
}
90+
$result = ExpandPayload -response $WebResult
7591
}
7692
}
7793
}

Rubrik/Private/Test-QueryParam.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@
7878
foreach ($param in $parameters) {
7979
# If the parameter name matches the query option name, build a query string
8080
if ($param.Name -eq $query) {
81-
Write-Debug ('Building Query with "{0}: {1}"' -f $resources.Query[$param.Name], (Get-Variable -Name $param.Name).Value)
81+
if ((Get-Variable -Name $param.Name).Value) {
82+
Write-Debug ('Building Query with "{0}: {1}"' -f $resources.Query[$param.Name], (Get-Variable -Name $param.Name).Value)
83+
}
8284
$querystring += Test-QueryObject -object (Get-Variable -Name $param.Name).Value -location $resources.Query[$param.Name] -params $querystring
8385
}
8486
# If the parameter alias matches the query option name, build a query string
8587
elseif ($param.Aliases -eq $query) {
86-
Write-Debug ('Building Query with "{0}: {1}"' -f (-join $resources.Query[$param.Aliases]), (Get-Variable -Name $param.Name).Value)
88+
if ((Get-Variable -Name $param.Name).Value) {
89+
Write-Debug ('Building Query with "{0}: {1}"' -f (-join $resources.Query[$param.Aliases]), (Get-Variable -Name $param.Name).Value)
90+
}
8791
$querystring += Test-QueryObject -object (Get-Variable -Name $param.Name).Value -location $resources.Query[$param.Aliases] -params $querystring
8892
}
8993
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function Test-UnicodeInString {
2+
<#
3+
.SYNOPSIS
4+
Test if a string contains non-ASCII characters
5+
6+
.DESCRIPTION
7+
Test if a string contains non-ASCII characters, returns true if it does, false if it does not. This function can be used to provide the correct character encoding for the different web cmdlets.
8+
#>
9+
param(
10+
$String
11+
)
12+
13+
[regex]::IsMatch($String, ".*[^\u0000-\u007F].*")
14+
}

Rubrik/Public/Get-RubrikVgfClusterStorage.ps1

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,59 @@
11
#requires -Version 3
22
function Get-RubrikVgfClusterStorage
33
{
4-
<#
5-
.SYNOPSIS
6-
Returns cluster free space in the case of Volume Group format upgrade
4+
<#
5+
.SYNOPSIS
6+
Returns cluster free space in the case of Volume Group format upgrade
77
8-
.DESCRIPTION
9-
The Get-RubrikVgfClusterStorage cmdlet is used to return projected space consumption
10-
on any number of volume groups if they are migrated to use the new format, and the
11-
cluster free space before and after the migration. If no Volume Group ID or list of
12-
ID is given, it will report the projected space consumption of migrating all Volume
13-
Groups that are currently using the old format.
8+
.DESCRIPTION
9+
The Get-RubrikVgfClusterStorage cmdlet is used to return projected space consumption
10+
on any number of volume groups if they are migrated to use the new format, and the
11+
cluster free space before and after the migration. If no Volume Group ID or list of
12+
ID is given, it will report the projected space consumption of migrating all Volume
13+
Groups that are currently using the old format.
1414
15-
.NOTES
16-
Written by Feng Lu for community usage
17-
github: fenglu42
15+
.NOTES
16+
Written by Feng Lu for community usage
17+
github: fenglu42
1818
19-
.LINK
20-
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/get-rubrikvgfclusterstorage
19+
.LINK
20+
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/get-rubrikvgfclusterstorage
2121
22-
.EXAMPLE
23-
Get-RubrikVgfClusterStorage -VGList VolumeGroup:::e0a04776-ab8e-45d4-8501-8da658221d74, VolumeGroup:::9136a7ef-4ad2-4bb9-bf28-961fb74d4322
22+
.EXAMPLE
23+
Get-RubrikVgfClusterStorage -VGList VolumeGroup:::e0a04776-ab8e-45d4-8501-8da658221d74, VolumeGroup:::9136a7ef-4ad2-4bb9-bf28-961fb74d4322
2424
25-
This will return projected space consumption on volume groups within the given Volume Group ID list, and cluster free space before and after migration.
25+
This will return projected space consumption on volume groups within the given Volume Group ID list, and cluster free space before and after migration.
2626
27-
.EXAMPLE
28-
Get-RubrikVgfClusterStorage
27+
.EXAMPLE
28+
Get-RubrikVgfClusterStorage
2929
30-
This will return projected space consumption of migrating all old-format volume groups on the Rubrik cluster, and cluster free space before and after migration.
30+
This will return projected space consumption of migrating all old-format volume groups on the Rubrik cluster, and cluster free space before and after migration.
3131
32-
.EXAMPLE
33-
Get-RubrikVgfClusterStorage -Hostname 'Server1'
32+
.EXAMPLE
33+
Get-RubrikVgfClusterStorage -Hostname 'Server1'
3434
35-
This will return projected space consumption of migrating all old-format volume groups from host "Server1", and cluster free space before and after migration.
35+
This will return projected space consumption of migrating all old-format volume groups from host "Server1", and cluster free space before and after migration.
3636
37-
.EXAMPLE
38-
Get-RubrikVgfClusterStorage -Hostname 'Server1' -SLA Gold
37+
.EXAMPLE
38+
Get-RubrikVgfClusterStorage -Hostname 'Server1' -SLA Gold
3939
40-
This will return projected space consumption of migrating all old-format volume groups of "Server1" that are protected by the Gold SLA Domain, and cluster free space before and after migration.
40+
This will return projected space consumption of migrating all old-format volume groups of "Server1" that are protected by the Gold SLA Domain, and cluster free space before and after migration.
4141
42-
.EXAMPLE
43-
Get-RubrikVgfClusterStorage -Relic
42+
.EXAMPLE
43+
Get-RubrikVgfClusterStorage -Relic
4444
45-
This will return projected space consumption of migrating all old-format, removed volume groups that were formerly protected by Rubrik, and cluster free space before and after migration.
45+
This will return projected space consumption of migrating all old-format, removed volume groups that were formerly protected by Rubrik, and cluster free space before and after migration.
4646
47-
.EXAMPLE
48-
Get-RubrikVgfClusterStorage -FailedLastSnapshot
47+
.EXAMPLE
48+
Get-RubrikVgfClusterStorage -FailedLastSnapshot
4949
50-
This will return projected space consumption of migrating all old-format volume groups that needs to be migrated to use fast VHDX format since they have failed the latest snapshot using the legacy backup format, and cluster free space before and after migration.
50+
This will return projected space consumption of migrating all old-format volume groups that needs to be migrated to use fast VHDX format since they have failed the latest snapshot using the legacy backup format, and cluster free space before and after migration.
5151
52-
# UsedFastVhdx not a param
53-
.EXAMPLE
54-
Get-RubrikVgfClusterStorage -UsedFastVhdx false
55-
56-
This will return projected space consumption on volume groups that did not use fast VHDX format in the latest snapshot.
57-
58-
.EXAMPLE
59-
Get-RubrikVgfClusterStorage -Id VolumeGroup:::205b0b65-b90c-48c5-9cab-66b95ed18c0f
60-
61-
This will return projected space consumption for the specified VolumeGroup ID, and 0 if this Volume Group uses fast VHDX format (no need for migration).
62-
#>
52+
.EXAMPLE
53+
Get-RubrikVgfClusterStorage -Id VolumeGroup:::205b0b65-b90c-48c5-9cab-66b95ed18c0f
54+
55+
This will return projected space consumption for the specified VolumeGroup ID, and 0 if this Volume Group uses fast VHDX format (no need for migration).
56+
#>
6357

6458
[CmdletBinding()]
6559
Param(

Rubrik/Public/Start-RubrikManagedVolumeSnapshot.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Start-RubrikManagedVolumeSnapshot
1818
https://rubrik.gitbook.io/rubrik-sdk-for-powershell/command-documentation/reference/start-rubrikmanagedvolumesnapshot
1919
2020
.EXAMPLE
21-
Start-ManagedVolumeSnapshot -id ManagedVolume:::f68ecd45-bdb9-46dd-aea4-8f041fb2dec2
21+
Start-RubrikManagedVolumeSnapshot -id ManagedVolume:::f68ecd45-bdb9-46dd-aea4-8f041fb2dec2
2222
2323
Open the specified managed volume for read/write operations
2424

Rubrik/Rubrik.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Jaap Brasser
55
#
6-
# Generated on: 2021/01/05
6+
# Generated on: 2021/07/06
77
#
88

99
@{
@@ -362,7 +362,7 @@
362362

363363
# Prerelease string of this module
364364

365-
Prerelease = 'RC3'
365+
# Prerelease = ''
366366

367367
# Flag to indicate whether the module requires explicit user acceptance for install/update
368368
# RequireLicenseAcceptance = $false

0 commit comments

Comments
 (0)