Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created May 19, 2018 07:02
Show Gist options
  • Select an option

  • Save SteveGilham/27a733c96b499c9a4ed9c63f6d73141a to your computer and use it in GitHub Desktop.

Select an option

Save SteveGilham/27a733c96b499c9a4ed9c63f6d73141a to your computer and use it in GitHub Desktop.
a more complex cmdlet in C++/CLI -- header file
#pragma once
using namespace System;
using namespace System::IO;
using namespace System::Management::Automation;
namespace PSBook { namespace Commands
{
[Cmdlet(VerbsCommon::Set, "FileTouchTime", DefaultParameterSetName = "Path", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact::Medium)]
public ref class SetFileTouchTimeCommand :
public PSCmdlet
{
public:
SetFileTouchTimeCommand(void);
[Parameter(ParameterSetName = "Path", Mandatory = true, Position = 1,
ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
property String ^ Path;
[Parameter(ParameterSetName = "FileInfo", Mandatory = true, Position = 1,
ValueFromPipeline = true)]
property FileInfo ^ FileInfo;
[Parameter]
property DateTime Date;
protected:
virtual void ProcessRecord(void) override;
private:
void TouchFile(System::IO::FileInfo ^ fileInfo);
void HandleFileNotFound(String ^ path, Exception ^ exception);
Resources::ResourceManager ^ rm;
};
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment