protected override void ProcessRecord()
        {
            // Get full path to source.
            ProviderInfo provider;
            string       fullSourcePath = GetResolvedProviderPathFromPSPath(SourcePath, out provider).FirstOrDefault();

            if (string.IsNullOrEmpty(fullSourcePath))
            {
                throw new ArgumentException(SourcePath);
            }

            // Get full path for destination file (which may not exist).
            string fullDestPath = null;
            string destFile     = Path.GetFileName(DestinationPath);
            string path         = GetResolvedProviderPathFromPSPath(
                Path.GetDirectoryName(DestinationPath), out provider).FirstOrDefault();

            if (path != null)
            {
                fullDestPath = Path.Combine(path, destFile);
            }
            if (string.IsNullOrEmpty(fullDestPath))
            {
                throw new ArgumentException(DestinationPath);
            }

            // Create job source adapter.
            FileCopyJobSourceAdapter jobSourceAdapter = new FileCopyJobSourceAdapter();

            // Create FileCopyJob parameters (source and destination paths).
            Dictionary <string, object> copyJobParameters = new Dictionary <string, object>();

            copyJobParameters.Add(FileCopyJobSourceAdapter.SourcePathProperty, fullSourcePath);
            copyJobParameters.Add(FileCopyJobSourceAdapter.DestinationPathProperty, fullDestPath);

            // Create job specification.
            JobInvocationInfo copyJobSpecification = new JobInvocationInfo(
                new JobDefinition(typeof(FileCopyJobSourceAdapter), string.Empty, Name),
                copyJobParameters);

            copyJobSpecification.Name = Name;

            // Create file copy job from job source adapter and start it.
            Job2 fileCopyJob = jobSourceAdapter.NewJob(copyJobSpecification);

            fileCopyJob.StartJob();

            WriteObject(fileCopyJob);
        }
        protected override void ProcessRecord()
        {
            // Get full path to source.
            ProviderInfo provider;
            string fullSourcePath = GetResolvedProviderPathFromPSPath(SourcePath, out provider).FirstOrDefault();
            if (string.IsNullOrEmpty(fullSourcePath))
            {
                throw new ArgumentException(SourcePath);
            }

            // Get full path for destination file (which may not exist).
            string fullDestPath = null;
            string destFile = Path.GetFileName(DestinationPath);
            string path = GetResolvedProviderPathFromPSPath(
                Path.GetDirectoryName(DestinationPath), out provider).FirstOrDefault();
            if (path != null)
            {
                fullDestPath = Path.Combine(path, destFile);
            }
            if (string.IsNullOrEmpty(fullDestPath))
            {
                throw new ArgumentException(DestinationPath);
            }

            // Create job source adapter.
            FileCopyJobSourceAdapter jobSourceAdapter = new FileCopyJobSourceAdapter();

            // Create FileCopyJob parameters (source and destination paths).
            Dictionary<string, object> copyJobParameters = new Dictionary<string, object>();
            copyJobParameters.Add(FileCopyJobSourceAdapter.SourcePathProperty, fullSourcePath);
            copyJobParameters.Add(FileCopyJobSourceAdapter.DestinationPathProperty, fullDestPath);

            // Create job specification.
            JobInvocationInfo copyJobSpecification = new JobInvocationInfo(
                new JobDefinition(typeof(FileCopyJobSourceAdapter), string.Empty, Name),
                copyJobParameters);
            copyJobSpecification.Name = Name;

            // Create file copy job from job source adapter and start it.
            Job2 fileCopyJob = jobSourceAdapter.NewJob(copyJobSpecification);
            fileCopyJob.StartJob();

            WriteObject(fileCopyJob);
        }