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     }
  • 相关阅读:
    bean的作用域和生命周期
    装配Bean的三种方式
    BeanFactory和ApplicationContext对比
    创建 Spring容器的三种方式
    约束
    三大范式
    事务
    EdgeRank
    TCP三次握手四次挥手
    Linux权限解释
  • 原文地址:https://www.cnblogs.com/xtypeu/p/3145960.html
Copyright © 2011-2022 走看看