From 1951a61699a274890fce1ec0a2661311e0b3ba75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Cat?= Date: Mon, 1 Oct 2018 17:01:15 -0700 Subject: [PATCH] Expand a few aliases --- Examples/ConditionalFormatting/CodeGenExamples.ps1 | 2 +- Examples/GenerateData/GenDataForCustomReport.ps1 | 2 +- Examples/Plot/PlotCos.ps1 | 2 +- Examples/TestRestAPI/TryIt.ps1 | 2 +- Export-Excel.ps1 | 2 +- Get-HtmlTable.ps1 | 4 ++-- Get-XYRange.ps1 | 6 +++--- GetExcelTable.ps1 | 2 +- InferData.ps1 | 2 +- Join-Worksheet.ps1 | 2 +- RemoveWorksheet.ps1 | 2 +- __tests__/First10Races.tests.ps1 | 4 ++-- plot.ps1 | 2 +- spikes/ConvertFrom-ExcelColumnName.ps1 | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Examples/ConditionalFormatting/CodeGenExamples.ps1 b/Examples/ConditionalFormatting/CodeGenExamples.ps1 index d81854a..861bc66 100644 --- a/Examples/ConditionalFormatting/CodeGenExamples.ps1 +++ b/Examples/ConditionalFormatting/CodeGenExamples.ps1 @@ -1,5 +1,5 @@ echo Last7Days LastMonth LastWeek NextMonth NextWeek ThisMonth ThisWeek Today Tomorrow Yesterday | - % { + Foreach-Object { $text = @" `$f = ".\testExport.xlsx" diff --git a/Examples/GenerateData/GenDataForCustomReport.ps1 b/Examples/GenerateData/GenDataForCustomReport.ps1 index 86e6d4c..1381fba 100644 --- a/Examples/GenerateData/GenDataForCustomReport.ps1 +++ b/Examples/GenerateData/GenDataForCustomReport.ps1 @@ -8,7 +8,7 @@ $sign=@{sign=echo + -} $location=@{location=echo Atlanta Newark Washington Chicago Philadelphia Houston Phoneix} -$(1..6 | % { +$(1..6 | Foreach-Object { $from=$to="" while($from -eq $to) { diff --git a/Examples/Plot/PlotCos.ps1 b/Examples/Plot/PlotCos.ps1 index e83980a..9be0cf5 100644 --- a/Examples/Plot/PlotCos.ps1 +++ b/Examples/Plot/PlotCos.ps1 @@ -1,6 +1,6 @@ try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} $plt = New-Plot -$plt.Plot((Get-Range 0 5 .02|%{[math]::Cos(2*[math]::pi*$_)})) +$plt.Plot((Get-Range 0 5 .02|Foreach-Object {[math]::Cos(2*[math]::pi*$_)})) $plt.SetChartSize(800,300) $plt.Show() \ No newline at end of file diff --git a/Examples/TestRestAPI/TryIt.ps1 b/Examples/TestRestAPI/TryIt.ps1 index 018f8b7..66c0037 100644 --- a/Examples/TestRestAPI/TryIt.ps1 +++ b/Examples/TestRestAPI/TryIt.ps1 @@ -2,6 +2,6 @@ try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} . $PSScriptRoot\TestAPIReadXls.ps1 -Test-APIReadXls $PSScriptRoot\testlist.xlsx | % { +Test-APIReadXls $PSScriptRoot\testlist.xlsx | Foreach-Object { Invoke-Pester -Script $_.fullname -PassThru -Show None } \ No newline at end of file diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index b2e336c..8bfa301 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -269,7 +269,7 @@ Verbose = $true } Remove-Item -Path $ExcelParams.Path -Force -EA Ignore - Get-Service | Select Name, Status, DisplayName, ServiceName | + Get-Service | Select-Object -Property Name, Status, DisplayName, ServiceName | Export-Excel @ExcelParams -ConditionalText $( New-ConditionalText Stop DarkRed LightPink New-ConditionalText Running Blue Cyan diff --git a/Get-HtmlTable.ps1 b/Get-HtmlTable.ps1 index df7f54c..6a7427f 100644 --- a/Get-HtmlTable.ps1 +++ b/Get-HtmlTable.ps1 @@ -21,9 +21,9 @@ function Get-HtmlTable { if(!$propertyNames) { if($cells[0].tagName -eq 'th') { - $propertyNames = @($cells | foreach {$_.innertext -replace ' ',''}) + $propertyNames = @($cells | ForEach-Object {$_.innertext -replace ' ',''}) } else { - $propertyNames = @(1..($cells.Count + 2) | % { "P$_" }) + $propertyNames = @(1..($cells.Count + 2) | Foreach-Object { "P$_" }) } continue } diff --git a/Get-XYRange.ps1 b/Get-XYRange.ps1 index 179679d..f28c8c8 100644 --- a/Get-XYRange.ps1 +++ b/Get-XYRange.ps1 @@ -1,7 +1,7 @@ function Get-XYRange { param($targetData) - $record = $targetData| select -First 1 + $record = $targetData | Select-Object -First 1 $p=$record.psobject.Properties.name $infer = for ($idx = 0; $idx -lt $p.Count; $idx++) { @@ -20,7 +20,7 @@ function Get-XYRange { } [PSCustomObject]@{ - XRange = $infer | ? {$_.datatype -match 'string'} | select -First 1 excelcolumn, name - YRange = $infer | ? {$_.datatype -match 'int|double'} |select -First 1 excelcolumn, name + XRange = $infer | Where-Object -FilterScript {$_.datatype -match 'string'} | Select-Object -First 1 -Property excelcolumn, name + YRange = $infer | Where-Object -FilterScript {$_.datatype -match 'int|double'} | Select-Object -First 1 -Property excelcolumn, name } } \ No newline at end of file diff --git a/GetExcelTable.ps1 b/GetExcelTable.ps1 index 1bd7903..dce52dc 100644 --- a/GetExcelTable.ps1 +++ b/GetExcelTable.ps1 @@ -89,7 +89,7 @@ function ConvertFrom-ExcelColumnName { $sum=0 $columnName.ToCharArray() | - ForEach { + ForEach-Object { $sum*=26 $sum+=[char]$_.tostring().toupper()-[char]'A'+1 } diff --git a/InferData.ps1 b/InferData.ps1 index add8f04..8badcfc 100644 --- a/InferData.ps1 +++ b/InferData.ps1 @@ -68,7 +68,7 @@ function Invoke-AllTests { ) $resultCount=0 - $tests.GetEnumerator() | ForEach { + $tests.GetEnumerator() | ForEach-Object { $result=& $_.Value $target diff --git a/Join-Worksheet.ps1 b/Join-Worksheet.ps1 index 57a5ca3..7a4f92d 100644 --- a/Join-Worksheet.ps1 +++ b/Join-Worksheet.ps1 @@ -24,7 +24,7 @@ .EXAMPLE > - PS> Get-WmiObject -Class win32_logicaldisk | select -Property DeviceId,VolumeName, Size,Freespace | + PS> Get-WmiObject -Class win32_logicaldisk | Select-Object -Property DeviceId,VolumeName, Size,Freespace | Export-Excel -Path "$env:computerName.xlsx" -WorkSheetname Volumes -NumberFormat "0,000" PS> Get-NetAdapter | Select-Object Name,InterfaceDescription,MacAddress,LinkSpeed | Export-Excel -Path "$env:COMPUTERNAME.xlsx" -WorkSheetname NetAdapter diff --git a/RemoveWorksheet.ps1 b/RemoveWorksheet.ps1 index 36be4f5..a62cfd5 100644 --- a/RemoveWorksheet.ps1 +++ b/RemoveWorksheet.ps1 @@ -29,6 +29,6 @@ Import-Module .\ImportExcel.psd1 -Force $names = Get-ExcelSheetInfo C:\Temp\testDelete.xlsx -$names | % { Remove-WorkSheet C:\Temp\testDelete.xlsx $_.Name} +$names | Foreach-Object { Remove-WorkSheet C:\Temp\testDelete.xlsx $_.Name} ##Remove-WorkSheet C:\Temp\testDelete.xlsx sheet6 \ No newline at end of file diff --git a/__tests__/First10Races.tests.ps1 b/__tests__/First10Races.tests.ps1 index 592e077..c8fd86e 100644 --- a/__tests__/First10Races.tests.ps1 +++ b/__tests__/First10Races.tests.ps1 @@ -18,7 +18,7 @@ Describe "Creating small named ranges with hyperlinks" { $worksheet = $excel.Workbook.Worksheets[1] $columns = $worksheet.Dimension.Columns - 1..$columns | foreach {Add-ExcelName -Range $worksheet.cells[$topRow,$_,$lastDataRow,$_]} #Test Add-Excel Name on its own (outside Export-Excel) + 1..$columns | ForEach-Object {Add-ExcelName -Range $worksheet.cells[$topRow,$_,$lastDataRow,$_]} #Test Add-Excel Name on its own (outside Export-Excel) $scwarnVar = $null Set-ExcelColumn -Worksheet $worksheet -StartRow $topRow -Heading "PlacesGained/Lost" ` @@ -39,7 +39,7 @@ Describe "Creating small named ranges with hyperlinks" { $ct = New-ConditionalText -Text "Ferrari" $ct2 = New-ConditionalText -Range $worksheet.Names["FinishPosition"].Address -ConditionalType LessThanOrEqual -Text 3 -ConditionalText Red -Background White #Test new-conditionalText in shortest and longest forms. #Create links for each group name (race) and Export them so they start at Cell A1; create a pivot table with definition just created, save the file and open in Excel - $results | foreach {(New-Object -TypeName OfficeOpenXml.ExcelHyperLink -ArgumentList "Sheet1!$($_.Name)" , "$($_.name) GP")} | #Test Exporting Hyperlinks with display property. + $results | ForEach-Object {(New-Object -TypeName OfficeOpenXml.ExcelHyperLink -ArgumentList "Sheet1!$($_.Name)" , "$($_.name) GP")} | #Test Exporting Hyperlinks with display property. Export-Excel -ExcelPackage $excel -AutoSize -PivotTableDefinition $pt -Calculate -ConditionalFormat $ct,$ct2 #Test conditional text rules in conditional format (orignally icon sets only ) $excel = Open-ExcelPackage $path diff --git a/plot.ps1 b/plot.ps1 index 05b193c..52935d1 100644 --- a/plot.ps1 +++ b/plot.ps1 @@ -155,7 +155,7 @@ class PSPlot { $sum=0 $columnName.ToCharArray() | - ForEach { + ForEach-Object { $sum*=26 $sum+=[char]$_.tostring().toupper()-[char]'A'+1 } diff --git a/spikes/ConvertFrom-ExcelColumnName.ps1 b/spikes/ConvertFrom-ExcelColumnName.ps1 index c4bf025..c704277 100644 --- a/spikes/ConvertFrom-ExcelColumnName.ps1 +++ b/spikes/ConvertFrom-ExcelColumnName.ps1 @@ -3,7 +3,7 @@ function ConvertFrom-ExcelColumnName { $sum=0 $columnName.ToCharArray() | - ForEach { + ForEach-Object { $sum*=26 $sum+=[char]$_.tostring().toupper()-[char]'A'+1 }