zoukankan      html  css  js  c++  java
  • powershell笔记

    Add-Content    追加内容到文件       echo "sss"  | Add-Content  C:Program Fileswmi_exportera.log
    get-content    查看文件内容 ....
    Set-Content    覆盖内容到文件 Set-Content D: emp est est.txt 'Welcome to TutorialsPoint'
    Test-Path        判断目录或文件是否存在 Test-Path -Path "${SERVICE_HOME}/WATCHDOG_PID"
    Remove-Item  递归删除目录或文件  Remove-Item 'D: empTest Folder' -Recurse
     $变量名字规则  注意$watchdog-log,这样会报错,不允许这样命名
     -ErrorAction SilentlyContinue防止报错

     Get-Process -name $process_name -ErrorAction SilentlyContinue

    remove-item ${SERVICE_HOME} -Recurse -Force -ErrorAction SilentlyContinue

    if ($?){...}#通过返回值判断是否报错

     .   /path/test.ps1

     载入函数,只能载入ps1结尾的文件。类似这种 .  /path/test.conf   ,会识别不到 

     sc.exe delete删除服务  sc.exe delete $ServiceName
     sc.exe create 添加服务  sc.exe create "Consul" binPath= 空格 "consul.exe arg1 arg2"
     sc.exe  start   启动服务  sc.exe  start “服务名”
     cmd /c 执行cmd命令,如bat文件  cmd /c start_wmi.bat
     curl的注意地方

     curl -XPUT "localhost:9200/mycompany/employee/1" -d "{"""first_name""":"""John""",","""interests""":["""sports""","""music"""]}"

    三个""",三个""",三个"""括住内容,代表是字符串,   整数是一个""

     cmd下查看service启动参数

     ps下查看service启动参数

     wmic process where caption="consul.exe" get commandline /value

    gwmi win32_process -Filter "name = 'consul.exe'"| select commandline | format-list

     系统默认变量

    $pid

    $args 

     暂停  cmd /c Pause | Out-Null
     执行ps1文件  powershell.exe -file "uninstall.ps1" 
     执行exe文件  Start-Process -FilePath "${CONSUL_HOME}/consul.exe" -ArgumentList "leave -http-addr=${CURRENT_IP}:${CONSUL_PORT}" -NoNewWindow 

     不输出内容

    类似linux的  2>/dev/null

     echo "lalallala"| Out-Null
       
       
       
       
       
       
       
       
       
       
       
  • 相关阅读:
    linux下查找文件中空行的行号
    JavaScript:jklyDB
    Chart:Amcharts
    Chart-template
    Miscellaneos:ISV
    杂项-模板
    Error-MVCr:找到了多个与 URL 匹配的控制器类型。如果多个控制器上的特性路由与请求的 URL 匹配,则可能会发生这种情况。
    Error-MVC:HTTP Error 500.19
    ASP.NET 网站管理工具
    HTML:Browser 对象
  • 原文地址:https://www.cnblogs.com/kevincaptain/p/10150179.html
Copyright © 2011-2022 走看看