• 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来释放空间。

  • 相关阅读:
    jQuery获取Select选择的Text和 Value(转)
    android学习---EditText
    android学习---Activity
    android学习---LinearLayout
    android学习---布局Layout
    android颜色码制表
    java面试题二
    java面试题一
    基本排序算法java实现
    Integer与int的区别
  • 原文地址:https://www.cnblogs.com/cwyang/p/5069119.html
Copyright © 2020-2023  润新知