Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: specify encoding for Out-File #93

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ Function Publish-BackupStatus {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand Down Expand Up @@ -2285,7 +2285,7 @@ Function Publish-BackupStatus {

if ($PsBoundParameters.ContainsKey('outputJson')) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $backupJsonSuffix
$allBackupStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allBackupStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allBackupStatusObject.Count -eq 0) { $addNoIssues = $true }
Expand Down Expand Up @@ -2342,7 +2342,7 @@ Function Publish-NsxtTransportNodeStatus {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson

)

Expand Down Expand Up @@ -2372,7 +2372,7 @@ Function Publish-NsxtTransportNodeStatus {

if ($PsBoundParameters.ContainsKey('outputJson')) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxtTransportJsonSuffix
$allNsxtTransportNodeStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allNsxtTransportNodeStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allNsxtTransportNodeStatusObject.Count -eq 0) {
Expand Down Expand Up @@ -2433,7 +2433,7 @@ Function Publish-NsxtTransportNodeTunnelStatus {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson

)

Expand Down Expand Up @@ -2461,7 +2461,7 @@ Function Publish-NsxtTransportNodeTunnelStatus {
}
if ($PsBoundParameters.ContainsKey('outputJson')) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxttntunnelJsonSuffix
$allNsxtTransportNodeTunnelStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allNsxtTransportNodeTunnelStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allNsxtTransportNodeTunnelStatusObject.Count -eq 0) { $addNoIssues = $true }
Expand Down Expand Up @@ -2523,7 +2523,7 @@ Function Publish-NsxtTier0BgpStatus {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand All @@ -2550,7 +2550,7 @@ Function Publish-NsxtTier0BgpStatus {
}
if ($PsBoundParameters.ContainsKey('outputJson')) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxttier0bgpJsonSuffix
$allNsxtTier0BgpStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allNsxtTier0BgpStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allNsxtTier0BgpStatusObject.Count -eq 0) { $addNoIssues = $true }
Expand Down Expand Up @@ -2618,7 +2618,7 @@ Function Publish-SnapshotStatus {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson

)

Expand Down Expand Up @@ -2660,7 +2660,7 @@ Function Publish-SnapshotStatus {

if ($PsBoundParameters.ContainsKey('outputJson')) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $snapshotJsonSuffix
$allSnapshotStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allSnapshotStatusObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {

Expand Down Expand Up @@ -2721,7 +2721,7 @@ Function Publish-LocalUserExpiry {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand Down Expand Up @@ -2771,7 +2771,7 @@ Function Publish-LocalUserExpiry {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $localuserexpiryJsonSuffix
Write-Output $json
Write-Output $$allPasswordExpiryObject
$allPasswordExpiryObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allPasswordExpiryObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allPasswordExpiryObject.Count -eq 0) { $addNoIssues = $true }
Expand Down Expand Up @@ -2830,7 +2830,7 @@ Function Publish-NsxtHealthNonSOS {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand Down Expand Up @@ -2858,7 +2858,7 @@ Function Publish-NsxtHealthNonSOS {

if ($PsBoundParameters.ContainsKey("outputJson")) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $nsxtCombinedHealthNonSOSJsonSuffix
$allNsxtHealthObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allNsxtHealthObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allNsxtHealthObject.Count -eq 0) { $addNoIssues = $true }
Expand Down Expand Up @@ -2999,7 +2999,7 @@ Function Publish-StorageCapacityHealth {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand Down Expand Up @@ -3051,7 +3051,7 @@ Function Publish-StorageCapacityHealth {
"esxi" = $allEsxiStorageCapacity
"datastore" = $allDatastoreStorageCapacity
}
$combinedJson | ConvertTo-JSON -Depth 10 | Out-File $json
$combinedJson | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"

} else {
Expand Down Expand Up @@ -4767,7 +4767,7 @@ Function Publish-ComponentConnectivityHealthNonSOS {
[Parameter (ParameterSetName = 'All-WorkloadDomains', Mandatory = $true)] [ValidateNotNullOrEmpty()] [Switch]$allDomains,
[Parameter (ParameterSetName = 'Specific-WorkloadDomain', Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$workloadDomain,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] $outputJson
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$outputJson
)

Try {
Expand All @@ -4792,7 +4792,7 @@ Function Publish-ComponentConnectivityHealthNonSOS {

if ($PsBoundParameters.ContainsKey("outputJson")) {
$json = Start-CreateOutputJsonDirectory -jsonFolder $outputJson -jsonFileSuffix $ComponentConnectivityHealthNonSOSJsonSuffix
$allConnectivityObject | ConvertTo-JSON -Depth 10 | Out-File $json
$allConnectivityObject | ConvertTo-JSON -Depth 10 | Out-File $json -Encoding ASCII
Write-Output "JSON Created at $json"
} else {
if ($allConnectivityObject.Count -eq 0) { $addNoIssues = $true }
Expand Down