@@ -155,7 +155,7 @@ function New-MarkdownHelp
155
155
156
156
if ($PSCmdlet.ParameterSetName -eq ' FromCommand' )
157
157
{
158
- $command | % {
158
+ $command | ForEach-Object {
159
159
if (-not (Get-Command $_ - EA SilentlyContinue))
160
160
{
161
161
throw " Command $_ not found in the session."
@@ -175,7 +175,7 @@ function New-MarkdownHelp
175
175
$iterator = $MamlFile
176
176
}
177
177
178
- $iterator | % {
178
+ $iterator | ForEach-Object {
179
179
if ($PSCmdlet.ParameterSetName -eq ' FromModule' )
180
180
{
181
181
if (-not (GetCommands - AsNames - module $_ ))
@@ -198,7 +198,7 @@ function New-MarkdownHelp
198
198
199
199
GetMamlObject - MamlFile $_ | ProcessMamlObjectToFile
200
200
201
- $CmdletNames += GetMamlObject - MamlFile $_ | % {$_.Name }
201
+ $CmdletNames += GetMamlObject - MamlFile $_ | ForEach-Object {$_.Name }
202
202
}
203
203
204
204
if ($WithModulePage )
@@ -245,7 +245,7 @@ function Get-MarkdownMetadata
245
245
}
246
246
else # FromFile)
247
247
{
248
- GetMarkdowFilesFromPath $Path - IncludeModulePage | % {
248
+ GetMarkdowFilesFromPath $Path - IncludeModulePage | ForEach-Object {
249
249
$md = Get-Content - Raw $_.FullName
250
250
[Markdown.MAML.Parser.MarkdownParser ]::GetYamlMetadata($md ) # yeild
251
251
}
@@ -287,15 +287,15 @@ function Update-MarkdownHelpSchema
287
287
288
288
end
289
289
{
290
- $markdown = $MarkdownFiles | % {
291
- cat - Raw $_.FullName
290
+ $markdown = $MarkdownFiles | ForEach-Object {
291
+ Get-Content - Raw $_.FullName
292
292
}
293
293
294
294
$model = GetMamlModelImpl $markdown - PreserveFormatting
295
295
$parseMode = GetParserMode - PreserveFormatting
296
296
$r = New-Object - TypeName Markdown.MAML.Renderer.MarkdownV2Renderer - ArgumentList $parseMode
297
297
298
- $model | % {
298
+ $model | ForEach-Object {
299
299
$name = $_.Name
300
300
# TODO: can we pass some metadata here?
301
301
# skipYamlHeader -eq $false
@@ -358,11 +358,11 @@ function Update-MarkdownHelp
358
358
}
359
359
360
360
361
- $MarkdownFiles | % {
361
+ $MarkdownFiles | ForEach-Object {
362
362
$file = $_
363
363
364
364
$filePath = $file.FullName
365
- $oldMarkdown = cat - Raw $filePath
365
+ $oldMarkdown = Get-Content - Raw $filePath
366
366
$oldModels = GetMamlModelImpl $oldMarkdown - PreserveFormatting
367
367
368
368
if ($oldModels.Count -gt 1 )
@@ -445,7 +445,7 @@ function Update-MarkdownHelpModule
445
445
# the idea is to find module name from landing page when it's available
446
446
if ($h .$script :MODULE_PAGE_MODULE_NAME )
447
447
{
448
- $module = $h .$script :MODULE_PAGE_MODULE_NAME | Select - First 1
448
+ $module = $h .$script :MODULE_PAGE_MODULE_NAME | Select-Object - First 1
449
449
log " Determined module name for $modulePath as $moduleName "
450
450
}
451
451
@@ -466,7 +466,7 @@ function Update-MarkdownHelpModule
466
466
}
467
467
468
468
$updatedCommands = $affectedFiles.BaseName
469
- $allCommands | % {
469
+ $allCommands | ForEach-Object {
470
470
if ( -not ($updatedCommands -contains $_ ) )
471
471
{
472
472
log " Creating new markdown for command $_ "
@@ -520,7 +520,7 @@ function New-ExternalHelp
520
520
521
521
end
522
522
{
523
- $MarkdownFiles | % {
523
+ $MarkdownFiles | ForEach-Object {
524
524
Write-Verbose " [New-ExternalHelp] Input markdown file $_ "
525
525
}
526
526
@@ -529,7 +529,7 @@ function New-ExternalHelp
529
529
if ($IsOutputContainer )
530
530
{
531
531
$defaultPath = Join-Path $OutputPath $script :DEFAULT_MAML_XML_OUTPUT_NAME
532
- $groups = $MarkdownFiles | group {
532
+ $groups = $MarkdownFiles | Group-Object {
533
533
$h = Get-MarkdownMetadata - Path $_.FullName
534
534
if ($h -and $h [$script :EXTERNAL_HELP_FILE_YAML_HEADER ])
535
535
{
@@ -545,11 +545,11 @@ function New-ExternalHelp
545
545
}
546
546
else
547
547
{
548
- $groups = $MarkdownFiles | group { $OutputPath }
548
+ $groups = $MarkdownFiles | Group-Object { $OutputPath }
549
549
}
550
550
551
551
foreach ($group in $groups ) {
552
- $maml = GetMamlModelImpl ( $group.Group | % { cat - Raw $_.FullName } )
552
+ $maml = GetMamlModelImpl ( $group.Group | ForEach-Object { Get-Content - Raw $_.FullName } )
553
553
$xml = $r.MamlModelToString ($maml , $false ) # skipPreambula is not used
554
554
$outPath = $group.Name # group name
555
555
Write-Verbose " Writing external help to $outPath "
@@ -580,7 +580,7 @@ function Get-HelpPreview
580
580
}
581
581
582
582
# this is Resolve-Path that resolves mounted drives (i.e. good for tests)
583
- $MamlFilePath = (ls $MamlFilePath ).FullName
583
+ $MamlFilePath = (Get-ChildItem $MamlFilePath ).FullName
584
584
585
585
# Read the malm file
586
586
$xml = [xml ](Get-Content $MamlFilePath - Raw - ea SilentlyContinue)
@@ -595,7 +595,7 @@ function Get-HelpPreview
595
595
$MamlCopyPath = [System.IO.Path ]::GetTempFileName()
596
596
try
597
597
{
598
- cp $MamlFilePath $MamlCopyPath
598
+ Copy-Item $MamlFilePath $MamlCopyPath
599
599
foreach ($command in $xml.helpItems.command.details.name )
600
600
{
601
601
$thisDefinition = @"
@@ -630,7 +630,7 @@ Microsoft.PowerShell.Core\Export-ModuleMember -Function @()
630
630
}
631
631
finally
632
632
{
633
- rm $MamlCopyPath
633
+ Remove-Item $MamlCopyPath
634
634
}
635
635
}
636
636
}
@@ -844,14 +844,14 @@ function GetMarkdowFilesFromPath
844
844
845
845
$MarkdownFiles = @ ()
846
846
if ($Path ) {
847
- $Path | % {
847
+ $Path | ForEach-Object {
848
848
if (Test-Path - PathType Leaf $_ )
849
849
{
850
850
$MarkdownFiles += Get-ChildItem $_
851
851
}
852
852
elseif (Test-Path - PathType Container $_ )
853
853
{
854
- $MarkdownFiles += ls $_ - Filter $filter
854
+ $MarkdownFiles += Get-ChildItem $_ - Filter $filter
855
855
}
856
856
else
857
857
{
@@ -889,7 +889,7 @@ function GetMamlModelImpl
889
889
# we need to pass it into .NET IEnumerable<MamlCommand> API
890
890
$res = New-Object ' System.Collections.Generic.List[Markdown.MAML.Model.MAML.MamlCommand]'
891
891
892
- $markdown | % {
892
+ $markdown | ForEach-Object {
893
893
$schema = GetSchemaVersion $_
894
894
$p = NewMarkdownParser - PreserveFormatting:$PreserveFormatting
895
895
$t = NewModelTransformer - schema $schema
@@ -900,7 +900,7 @@ function GetMamlModelImpl
900
900
$maml = $t.NodeModelToMamlModel ($model )
901
901
902
902
# flatten
903
- $maml | % { $res.Add ($_ ) }
903
+ $maml | ForEach-Object { $res.Add ($_ ) }
904
904
}
905
905
906
906
return @ (, $res )
@@ -989,7 +989,7 @@ function UpdateMamlObject
989
989
}
990
990
991
991
# Online Version URL
992
- if (-not ($MamlCommandObject.Links | ? {$_.LinkName -eq ' Online Version:' } )) {
992
+ if (-not ($MamlCommandObject.Links | Where-Object {$_.LinkName -eq ' Online Version:' } )) {
993
993
$mamlLink = New-Object - TypeName Markdown.MAML.Model.MAML.MamlLink
994
994
$mamlLink.LinkName = ' Online Version:'
995
995
if ($OnlineVersionUrl )
@@ -1137,8 +1137,8 @@ function GetHelpFileName
1137
1137
1138
1138
# overwise, lets guess it
1139
1139
$module = @ ($CommandInfo.Module ) + ($CommandInfo.Module.NestedModules ) |
1140
- ? {$_.ModuleType -ne ' Manifest' } |
1141
- ? {$_.ExportedCommands.Keys -contains $CommandInfo.Name }
1140
+ Where-Object {$_.ModuleType -ne ' Manifest' } |
1141
+ Where-Object {$_.ExportedCommands.Keys -contains $CommandInfo.Name }
1142
1142
1143
1143
if (-not $module )
1144
1144
{
@@ -1149,7 +1149,7 @@ function GetHelpFileName
1149
1149
if ($module.Count -gt 1 )
1150
1150
{
1151
1151
Write-Warning " [GetHelpFileName] Found $ ( $module.Count ) modules for $ ( $CommandInfo.Name ) "
1152
- $module = $module | Select - First 1
1152
+ $module = $module | Select-Object - First 1
1153
1153
}
1154
1154
1155
1155
$moduleItem = Get-Item - Path $module.Path
@@ -1250,7 +1250,7 @@ function NewModuleLandingPage
1250
1250
$Content += " ---`r`n`r`n # $ModuleName Module`r`n ## Description`r`n "
1251
1251
$Content += " {{Manually Enter Description Here}}`r`n`r`n ## $ModuleName Cmdlets`r`n "
1252
1252
1253
- $CmdletNames | % {
1253
+ $CmdletNames | ForEach-Object {
1254
1254
$Content += " ### [" + $_ + " ](" + $_ + " .md)`r`n {{Manually Enter $_ Description Here}}`r`n`r`n "
1255
1255
}
1256
1256
@@ -1362,7 +1362,7 @@ function GetMamlObject
1362
1362
# Provides Name, CommandType, and Empty Module name from MAML generated module in the $command object.
1363
1363
# Otherwise loads the results from Get-Command <Cmdlet> into the $command object
1364
1364
1365
- $HelpCollection | % {
1365
+ $HelpCollection | ForEach-Object {
1366
1366
1367
1367
$Help = $_
1368
1368
@@ -1549,7 +1549,7 @@ function ConvertPsObjectsToMamlModel
1549
1549
[Markdown.MAML.Model.MAML.MamlParameter ]$ParameterObject
1550
1550
)
1551
1551
1552
- $HelpEntry = $Help.parameters.parameter | WHERE {$_.Name -eq $ParameterObject.Name }
1552
+ $HelpEntry = $Help.parameters.parameter | Where-Object {$_.Name -eq $ParameterObject.Name }
1553
1553
1554
1554
$ParameterObject.DefaultValue = $HelpEntry.defaultValue
1555
1555
$ParameterObject.VariableLength = $HelpEntry.variableLength -eq ' True'
@@ -1571,7 +1571,7 @@ function ConvertPsObjectsToMamlModel
1571
1571
}
1572
1572
}
1573
1573
1574
- $syntaxParam = $Help.syntax.syntaxItem.parameter | ? {$_.Name -eq $Parameter.Name } | Select - First 1
1574
+ $syntaxParam = $Help.syntax.syntaxItem.parameter | Where-Object {$_.Name -eq $Parameter.Name } | Select-Object - First 1
1575
1575
if ($syntaxParam )
1576
1576
{
1577
1577
# otherwise we could potentialy get it from Reflection but not doing it for now
@@ -1596,7 +1596,7 @@ function ConvertPsObjectsToMamlModel
1596
1596
if (IsCommonParameterName $Parameter.Name - Workflow:$IsWorkflow )
1597
1597
{
1598
1598
# but don't ignore them, if they have explicit help entries
1599
- if ($Help.parameters.parameter | ? {$_.Name -eq $Parameter.Name })
1599
+ if ($Help.parameters.parameter | Where-Object {$_.Name -eq $Parameter.Name })
1600
1600
{
1601
1601
}
1602
1602
else
@@ -1753,7 +1753,7 @@ function ConvertPsObjectsToMamlModel
1753
1753
# region Inputs
1754
1754
$Inputs = @ ()
1755
1755
1756
- $Help.inputTypes.inputType | % {
1756
+ $Help.inputTypes.inputType | ForEach-Object {
1757
1757
$InputObject = New-Object - TypeName Markdown.MAML.Model.MAML.MamlInputOutput
1758
1758
$InputObject.TypeName = $_.type.name
1759
1759
$InputObject.Description = $_.description.Text | AddLineBreaksForParagraphs
@@ -1769,7 +1769,7 @@ function ConvertPsObjectsToMamlModel
1769
1769
# region Outputs
1770
1770
$Outputs = @ ()
1771
1771
1772
- $Help.returnValues.returnValue | % {
1772
+ $Help.returnValues.returnValue | ForEach-Object {
1773
1773
$OutputObject = New-Object - TypeName Markdown.MAML.Model.MAML.MamlInputOutput
1774
1774
$OutputObject.TypeName = $_.type.name
1775
1775
$OutputObject.Description = $_.description.Text | AddLineBreaksForParagraphs
@@ -1790,13 +1790,13 @@ function ConvertPsObjectsToMamlModel
1790
1790
[string ]$Name
1791
1791
)
1792
1792
1793
- $defaultSyntax = $MamlCommandObject.Syntax | ? { $Command.DefaultParameterSet -eq $_.ParameterSetName }
1793
+ $defaultSyntax = $MamlCommandObject.Syntax | Where-Object { $Command.DefaultParameterSet -eq $_.ParameterSetName }
1794
1794
# default syntax should have a priority
1795
1795
$syntaxes = @ ($defaultSyntax ) + $MamlCommandObject.Syntax
1796
1796
1797
1797
foreach ($s in $syntaxes )
1798
1798
{
1799
- $param = $s.Parameters | ? { $_.Name -eq $Name }
1799
+ $param = $s.Parameters | Where-Object { $_.Name -eq $Name }
1800
1800
if ($param )
1801
1801
{
1802
1802
return $param
0 commit comments