zoukankan      html  css  js  c++  java
  • Powershell 学习笔记【持续更新】

    1. 判断一个对象是不是空可以用 $null来比较

    2. 判断一个字符串是不是空的: [string]::IsNullOrEmpty(...)

    3. 在powershell中把结果输出为一个CSV格式的文本文件的方法, 好处自己想

    # Get the current script execution path so our CSV file gets saved back there
    [string]$curloc = get-location
    out-file -filepath "$curlocWADBs.csv"
    
    # Create the empty CSV array
    $arrCSV = @()
    
     # Create the empty record object and start populating it with information
           $objDB = "" | select DBName,DBStatus,WebApplication
           $objDB.DBName = $database.name
           $objDB.DBStatus = $database.status
           $objDB.WebApplication = $webapp.URL
    
    # Add the new record as a new node in the CSV array
      $arrCSV += $objDB 
    
     # Now that we’ve added all of the records to the array we need to write the CSV array out to the file system
        $arrCSV | Export-Csv "$curlocWADBs.csv" -NoTypeInformation 

    4. Powershell在遍历SharePoint的时候也要注意释放spsite和spweb,要不然也会占用服务器大量的空间。最简单的方法是在代码开始的时候写

    start-spassignment -global

    结束的时候用 stop-spassignment -global来释放空间。

  • 相关阅读:
    Linux系统网络文件配置
    Linux系统修改日期时间
    8、mysql索引
    7、mysql正则表达式、事务、alter命令
    6、mysql数据操作
    5、mysql数据类型
    4、mysql数据库操作
    3、mysql管理
    2、mysql安装
    1、mysql教程
  • 原文地址:https://www.cnblogs.com/cwyang/p/5069119.html
Copyright © 2011-2022 走看看