zoukankan      html  css  js  c++  java
  • Powershell点滴

    1. 如何表达枚举类型?
    [StringSplitOptions] $option = "None"
    [StringSplitOptions] $option = "RemoveEmptyEntries"
     
    2. 在bat中调用执行Powershell文件(相对路径)
    powershell.exe -Command "& {.\Script1.ps1}"
     
    3. 加入-NoExit参数执行ps1文件
    PowerShell.exe -NoExit "& 'C:\Program Files\...\sharepoint.ps1'"
     
    4. 通用参数-confirm -ErrorAction
    -Confirm $false
    -ErrorAction "SilentlyContinue"
     
    5. 创建对象并传递参数
    $date = New-Object -TypeName System.DateTime -ArgumentList @(1882,7,4,0,0,0)
     
    6. 创建COM对象
    $ie = New-Object -ComObject "InternetExplorer.Application"
     
    7. 执行Powershell脚本文件并传入命名参数
    #powershell -noexit -file "C:\Users\Terry\MyPSScripts\test01.ps1" -par1 "hello world" -par2 great
    在文件中有对参数的定义:param($par1, $par2)
     
    8. 获取给定路径的父目录
    split-path “c:\test\error.log” #会返回 c:\test, 等价于 split-path “c:\test\error.log” –Parent
    split-path “c:\test\error.log” -leaf #会返回 error.log
     
    9. 得到脚本文件所在的目录
    $MyInvocation.MyCommand.Path 比较好用
    $MyInvocation.InvocationName 不可靠,它可以是”&”也可以是实际的脚本全路径

  • 相关阅读:
    meanshift聚类的实现
    birch聚类算法
    DBSCAN聚类算法的实现
    discrete adaboost的C++实现
    kd-tree的实现
    红黑树的实现——插入
    24位位图转8位灰度图
    将RGB数据写入BMP位图文件
    splay树的实现
    AVL树的实现
  • 原文地址:https://www.cnblogs.com/teamleader/p/2318706.html
Copyright © 2011-2022 走看看