2.6 KiB
Windows PowerShell Job Source Adapter Sample
This sample shows how to derive a FileCopyJob class from the Job2 type and a FileCopyJobSourceAdapter class from the JobSourceAdapter type.
The FileCopyJob sample class is implemented to perform simple file system listening and file copying functions. The FileCopyJobSourceAdapter implementation creates FileCopyJob objects and allows manipulation of these objects through Windows PowerShell's Get-Job, Suspend-Job, Resume-Job, Stop-Job, and Remove-Job cmdlets.
Sample Objectives
This sample demonstrates the following:
- Creating a FileCopyJob job derived from a Job2 type.
- Creating a FileCopyJobSourceAdapter derived from a JobSourceAdapter type.
- Importing the assembly and the FileCopyJobSourceAdapter into a PowerShell console so that existing PowerShell job cmdlets can be used to manipulate FileCopyJob job objects.
Related topics
Conceptual
Reference
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.
-
Make sure the JobSourceAdapter project references the System.Management.Automation.dll assembly.
-
Press F7 or use Build > Build Solution to build the sample.
The executable will be built in the default \bin or \bin\Debug directory.
Run the sample
- Run
Import-Modulewith the full path to the sample DLL. - Run the
Get-FileCopyJobcmdlet that was imported from the assembly. Create one or more FileCopyJob objects passing in the name, text source file, and text destination file paths. - Use
Get-Jobto see the FileCopyJob jobs that were created. - Use
Suspend-JobandResume-Jobto suspend and resume the jobs. - Use
Stop-JobandRemove-Jobto stop and remove the jobs from the JobSourceAdapter repository.