zoukankan      html  css  js  c++  java
  • 2013-06-20

    Provides methods that are used to create a pipeline of commands and invoke those commands either synchronously or asynchronously within a runspace. This class also provides access to the output streams that contain data that is generated when the commands are invoked. This class is primarily intended for host applications that programmatically use Windows PowerShell to perform tasks. This class is introduced in Windows PowerShell 2.0

    csc /target:library/reference:.System.Management.Automation.dll ps-2-1.cs

    To retain these changes, you can create a Windows PowerShell profile and add the aliases, functions, and variables to the profiles. The profile is loaded every time that Windows PowerShell starts<http://technet.microsoft.com/en-us/library/bb613488.aspx>

     1 using System;
     2 using System.Management.Automation;
     3 using System.ComponentModel;
     4 using System.IO;
     5 [Cmdlet("Touch","File")]
     6     public class TouchFileCommand:PSCmdlet
     7     {
     8         private string path = null;
     9         [Parameter]
    10         public string Path
    11         {
    12             get
    13             {
    14                 return path;
    15             }
    16             set
    17             {
    18                 path = value;
    19             }
    20         }
    21         protected override void ProcessRecord()
    22         {
    23             if(File.Exists(path))
    24             {
    25                 File.SetLastWriteTime(path,DateTime.Now );
    26             }
    27         }
    28     }
  • 相关阅读:
    左耳听风
    极客时间-算法
    极客时间-左耳听风阅读笔记
    涨知识
    学做饭
    开发流程
    线上问题复盘
    反思学习复习练习
    系统安全(转)
    单元测试
  • 原文地址:https://www.cnblogs.com/xtypeu/p/3145960.html
Copyright © 2011-2022 走看看