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

  • 相关阅读:
    Tomcat 服务器体系结构
    tomcat的下载和启动
    tomcat解决端口号占用问题
    我的wmware
    Xshell的使用
    GCC的-wl,-rpath=参数
    Matlab图像处理(01)-Matlab基础
    CMake最好的学习资料
    使用valgrind进行内存泄漏和非法内存操作检测
    CLion提示can't find stdio.h等错误
  • 原文地址:https://www.cnblogs.com/cwyang/p/5069119.html
Copyright © 2011-2022 走看看