Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function StupidGetContentWrapper()
- {
- [CmdletBinding(DefaultParameterSetName="None")]
- param
- (
- [Parameter(Mandatory, Position = 0, ValueFromPipelineByPropertyName)]
- [Alias("PSPath")]
- [string] $FilePath,
- [Parameter(Mandatory, ParameterSetName="Skip")]
- [Alias("Skip")]
- [int] $SkipCount,
- [Parameter(Mandatory, ParameterSetName="Tail")]
- [Alias("Tail")]
- [int] $TailCount
- )
- Process
- {
- $getContentArgs = @{
- Path = $FilePath
- }
- if ($PSBoundParameters.ContainsKey("TailCount"))
- {
- $getContentArgs.Tail = $TailCount
- }
- # Get the content of the specified file
- $content = @(Get-Content @getContentArgs)
- if ($PSBoundParameters.ContainsKey("SkipCount") -and $null -ne $content -and $content.Count -gt 0)
- {
- $content | Select-Object -First $SkipCount
- # Or without Select-Object and using the indexer instead...
- # $content[($SkipCount-1)..$content.Count]
- }
- else
- {
- $content
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement