Skip to content

Commit

Permalink
Merge pull request #49 from sethworks/convert
Browse files Browse the repository at this point in the history
Convert
  • Loading branch information
sethvs authored Mar 18, 2024
2 parents d51482c + 1c7acd8 commit 8443228
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions docs/en-us/Get-DiskSmartInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Gets disk SMART information

### ComputerName (Default)
```
Get-DiskSmartInfo [[-ComputerName] <String[]>] [-ShowConverted] [-CriticalAttributesOnly]
Get-DiskSmartInfo [[-ComputerName] <String[]>] [-Convert] [-CriticalAttributesOnly]
[-DiskNumber <Int32[]>] [-DiskModel <String[]>] [-AttributeID <Int32[]>] [-AttributeIDHex <String[]>]
[-AttributeName <String[]>] [-Quiet] [-ShowHistory] [-UpdateHistory] [-Credential <PSCredential>]
[<CommonParameters>]
```

### CimSession
```
Get-DiskSmartInfo -CimSession <CimSession[]> [-ShowConverted] [-CriticalAttributesOnly]
Get-DiskSmartInfo -CimSession <CimSession[]> [-Convert] [-CriticalAttributesOnly]
[-DiskNumber <Int32[]>] [-DiskModel <String[]>] [-AttributeID <Int32[]>] [-AttributeIDHex <String[]>]
[-AttributeName <String[]>] [-Quiet] [-ShowHistory] [-UpdateHistory] [<CommonParameters>]
```
Expand Down Expand Up @@ -64,7 +64,7 @@ Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -ShowConverted
### -Convert
Adds converted data for some of the attributes.
These conversions are defined as ConvertScriptBlock property of attributes, listed in
Expand Down Expand Up @@ -352,7 +352,7 @@ The command gets disk SMART information.

### Example 2: Converted data
```powershell
Get-DiskSmartInfo -ShowConverted
Get-DiskSmartInfo -Convert
```

```
Expand Down
8 changes: 4 additions & 4 deletions docs/ru-ru/Get-DiskSmartInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ schema: 2.0.0

### ComputerName (Default)
```
Get-DiskSmartInfo [[-ComputerName] <String[]>] [-ShowConverted] [-CriticalAttributesOnly]
Get-DiskSmartInfo [[-ComputerName] <String[]>] [-Convert] [-CriticalAttributesOnly]
[-DiskNumber <Int32[]>] [-DiskModel <String[]>] [-AttributeID <Int32[]>] [-AttributeIDHex <String[]>]
[-AttributeName <String[]>] [-Quiet] [-ShowHistory] [-UpdateHistory] [-Credential <PSCredential>]
[<CommonParameters>]
```

### CimSession
```
Get-DiskSmartInfo -CimSession <CimSession[]> [-ShowConverted] [-CriticalAttributesOnly]
Get-DiskSmartInfo -CimSession <CimSession[]> [-Convert] [-CriticalAttributesOnly]
[-DiskNumber <Int32[]>] [-DiskModel <String[]>] [-AttributeID <Int32[]>] [-AttributeIDHex <String[]>]
[-AttributeName <String[]>] [-Quiet] [-ShowHistory] [-UpdateHistory] [<CommonParameters>]
```
Expand Down Expand Up @@ -64,7 +64,7 @@ Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -ShowConverted
### -Convert
Параметр добавляет ковертированные данные для определенных атрибутов.
Механизмы конвертации заданы в качестве свойства ConvertScriptBlock атрибутов,
Expand Down Expand Up @@ -361,7 +361,7 @@ SMARTData:

### Example 2: Конвертированные данные
```powershell
Get-DiskSmartInfo -ShowConverted
Get-DiskSmartInfo -Convert
```

```
Expand Down
8 changes: 4 additions & 4 deletions en-us/DiskSmartInfo-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Adds converted data for some of the attributes.</maml:para>
<maml:para>These conversions are defined as ConvertScriptBlock property of attributes, listed in attributes/default.ps1 and attributes/proprietary.ps1 files.</maml:para>
Expand Down Expand Up @@ -381,7 +381,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Adds converted data for some of the attributes.</maml:para>
<maml:para>These conversions are defined as ConvertScriptBlock property of attributes, listed in attributes/default.ps1 and attributes/proprietary.ps1 files.</maml:para>
Expand Down Expand Up @@ -555,7 +555,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Adds converted data for some of the attributes.</maml:para>
<maml:para>These conversions are defined as ConvertScriptBlock property of attributes, listed in attributes/default.ps1 and attributes/proprietary.ps1 files.</maml:para>
Expand Down Expand Up @@ -779,7 +779,7 @@ SMARTData:
</command:example>
<command:example>
<maml:title>------------------ Example 2: Converted data ------------------</maml:title>
<dev:code>Get-DiskSmartInfo -ShowConverted
<dev:code>Get-DiskSmartInfo -Convert

Disk: 0: Disk model
PNPDeviceId: Disk PNPDeviceId
Expand Down
2 changes: 1 addition & 1 deletion en-us/about_DiskSmartInfo_attributes.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ DataType is an enum type value, that defines attribute data structure.
IsCritical is a boolean, specifying whether an attribute is critical.

ConvertScriptBlock is a ScriptBlock type value, that defines conversion process,
that is used by the the Get-DiskSmartInfo command with the -ShowConverted parameter.
that is used by the the Get-DiskSmartInfo command with the -Convert parameter.


PROPRIETARY ATTRIBUTES
Expand Down
8 changes: 4 additions & 4 deletions functions/DiskSmartInfo.functions.internal.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function inGetDiskSmartInfo
{
Param (
[Microsoft.Management.Infrastructure.CimSession[]]$Session,
[switch]$ShowConverted,
[switch]$Convert,
[switch]$CriticalAttributesOnly,
[int[]]$DiskNumbers,
[string[]]$DiskModels,
Expand Down Expand Up @@ -137,23 +137,23 @@ function inGetDiskSmartInfo
$attribute.Add("DataHistory", $null)
}
}
if ($ShowConverted)
if ($Convert)
{
$attribute.Add("DataConverted", $(inConvertData -attribute $attribute))
}

$attributeObject = [PSCustomObject]$attribute
$attributeObject | Add-Member -TypeName "DiskSmartAttribute"

if ($ShowHistory -and $ShowConverted)
if ($ShowHistory -and $Convert)
{
$attributeObject | Add-Member -TypeName 'DiskSmartAttribute#DataHistoryDataConverted'
}
elseif ($ShowHistory)
{
$attributeObject | Add-Member -TypeName 'DiskSmartAttribute#DataHistory'
}
elseif ($ShowConverted)
elseif ($Convert)
{
$attributeObject | Add-Member -TypeName 'DiskSmartAttribute#DataConverted'
}
Expand Down
4 changes: 2 additions & 2 deletions functions/DiskSmartInfo.functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Get-DiskSmartInfo
[string[]]$ComputerName,
[Parameter(ValueFromPipeline,ParameterSetName='CimSession')]
[CimSession[]]$CimSession,
[switch]$ShowConverted,
[switch]$Convert,
[switch]$CriticalAttributesOnly,
[Alias('Index','Number','DeviceId')]
[Parameter(ValueFromPipelineByPropertyName)]
Expand Down Expand Up @@ -172,7 +172,7 @@ function Get-DiskSmartInfo

inGetDiskSmartInfo `
-Session $scd.CimSession `
-ShowConverted:$ShowConverted `
-Convert:$Convert `
-CriticalAttributesOnly:$CriticalAttributesOnly `
-DiskNumbers $scd.DiskNumber `
-DiskModels $DiskModel `
Expand Down
8 changes: 4 additions & 4 deletions ru-ru/DiskSmartInfo-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Параметр добавляет ковертированные данные для определенных атрибутов.</maml:para>
<maml:para>Механизмы конвертации заданы в качестве свойства ConvertScriptBlock атрибутов, перечисленных в файлах attributes/default.ps1 и attributes/proprietary.ps1.</maml:para>
Expand Down Expand Up @@ -381,7 +381,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Параметр добавляет ковертированные данные для определенных атрибутов.</maml:para>
<maml:para>Механизмы конвертации заданы в качестве свойства ConvertScriptBlock атрибутов, перечисленных в файлах attributes/default.ps1 и attributes/proprietary.ps1.</maml:para>
Expand Down Expand Up @@ -555,7 +555,7 @@ Description : (Vendor-specific raw value.) The raw value has different struct
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>ShowConverted</maml:name>
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>Параметр добавляет ковертированные данные для определенных атрибутов.</maml:para>
<maml:para>Механизмы конвертации заданы в качестве свойства ConvertScriptBlock атрибутов, перечисленных в файлах attributes/default.ps1 и attributes/proprietary.ps1.</maml:para>
Expand Down Expand Up @@ -779,7 +779,7 @@ SMARTData:
</command:example>
<command:example>
<maml:title>-------------- Example 2: Конвертированные данные --------------</maml:title>
<dev:code>Get-DiskSmartInfo -ShowConverted
<dev:code>Get-DiskSmartInfo -Convert

Disk: 0: Disk model
PNPDeviceId: Disk PNPDeviceId
Expand Down
2 changes: 1 addition & 1 deletion ru-ru/about_DiskSmartInfo_attributes.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DataType - это значение типа enum, указывающее стр
IsCritical - это логическое значение, определяющее, является ли атрибут критическим.

ConvertScriptBlock - это значение типа ScriptBlock, задающее механизм конвертации
значения атрибута, используемый параметром -ShowConverted команды Get-DiskSmartInfo.
значения атрибута, используемый параметром -Convert команды Get-DiskSmartInfo.


СОБСТВЕННЫЕ АТРИБУТЫ ПРОИЗВОДИТЕЛЕЙ
Expand Down
4 changes: 2 additions & 2 deletions tests/DiskSmartInfo.history.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Describe "History" {
}
}

Context "-ShowHistory -ShowConverted" {
Context "-ShowHistory -Convert" {

BeforeAll {
mock Get-CimInstance -MockWith { $diskSmartDataHDD1, $diskSmartDataHDD2, $diskSmartDataSSD1 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classSmartData } -ModuleName DiskSmartInfo
Expand All @@ -353,7 +353,7 @@ Describe "History" {
(Get-Content -Path 'TestDrive:/localhost.txt') -replace '"Data": 358', '"Data": 357' | Set-Content -Path 'TestDrive:/localhost.txt'
}

$diskSmartInfo = Get-DiskSmartInfo -ShowHistory -ShowConverted
$diskSmartInfo = Get-DiskSmartInfo -ShowHistory -Convert
}

It "Object is of proper type" {
Expand Down
6 changes: 3 additions & 3 deletions tests/DiskSmartInfo.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ Describe "Get-DiskSmartInfo" {
}
}

Context "-ShowConverted" {
Context "-Convert" {

BeforeAll {
mock Get-CimInstance -MockWith { $diskSmartDataHDD1, $diskSmartDataSSD1 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classSmartData } -ModuleName DiskSmartInfo
mock Get-CimInstance -MockWith { $diskThresholdsHDD1, $diskThresholdsSSD1 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classThresholds } -ModuleName DiskSmartInfo
mock Get-CimInstance -MockWith { $diskFailurePredictStatusHDD1, $diskFailurePredictStatusSSD1 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classFailurePredictStatus } -ModuleName DiskSmartInfo
mock Get-CimInstance -MockWith { $diskDriveHDD1, $diskDriveSSD1 } -ParameterFilter { $ClassName -eq $classDiskDrive } -ModuleName DiskSmartInfo
$diskSmartInfo = Get-DiskSmartInfo -ShowConverted
$diskSmartInfo = Get-DiskSmartInfo -Convert
}

It "Converts Spin-Up Time" {
Expand Down Expand Up @@ -322,7 +322,7 @@ Describe "Get-DiskSmartInfo" {
mock Get-CimInstance -MockWith { $diskThresholdsSSD1, $diskThresholdsHFSSSD1, $diskThresholdsSSD2 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classThresholds } -ModuleName DiskSmartInfo
mock Get-CimInstance -MockWith { $diskFailurePredictStatusSSD1, $diskFailurePredictStatusHFSSSD1, $diskFailurePredictStatusSSD2 } -ParameterFilter { $Namespace -eq $namespaceWMI -and $ClassName -eq $classFailurePredictStatus } -ModuleName DiskSmartInfo
mock Get-CimInstance -MockWith { $diskDriveSSD1, $diskDriveHFSSSD1, $diskDriveSSD2 } -ParameterFilter { $ClassName -eq $classDiskDrive } -ModuleName DiskSmartInfo
$diskSmartInfo = Get-DiskSmartInfo -ShowConverted
$diskSmartInfo = Get-DiskSmartInfo -Convert
}

It "Has 3 DiskSmartInfo objects" {
Expand Down

0 comments on commit 8443228

Please sign in to comment.