Windows PowerShell Supports Paging 01 Sample
This sample shows how to implement a cmdlet called Get-Numbers that supports paging operations. The Get-Numbers cmdlet generates up to 100 consecutive numbers starting from 0. The IncludeTotalCount, Skip, and First parameters enable the user to perform paging operations on the set of numbers returned by the cmdlet.
Sample Objectives
This sample demonstrates the following:
- Usage of the SupportsPaging attribute to implement paging functionality.
Related topics
Operating system requirements
Client
Windows 8.1
Server
Windows Server 2012 R2
Build the sample
-
Start Microsoft Visual Studio and select File > Open > Project/Solution.
-
Go to the directory named for the sample, and double-click the Visual Studio Solution (.sln) file.
-
Press F7 or use Build > Build Solution to build the sample.
The library will be built in the default \bin or \bin\Debug directory.
Run the sample
Running the C# Sample
- Store the assembly in the following module folder: [user]/Documents/WindowsPowerShell/Modules/SupportsPaging01
- Start Windows PowerShell.
- Run the following command:
Import-Module SupportsPaging01(This command loads the assembly into Windows PowerShell.) - Run the
Get-Numberscmdlet.
Running the Windows PowerShell Script Sample
-
Open Windows PowerShell.
-
Navigate to the directory where the SupportsPaging01.ps1 script is stored.
By default, the script is located in the .../PowerShell/SupportsPaging/SupportsPaging_Script/CS directory.
-
Dot source the script by running the following command:
. .\SupportsPaging01.ps1