首页 > 系统服务 > 详细

Powershell 学习笔记【持续更新】

时间:2015-12-23 12:44:10      阅读:242      评论:0      收藏:0      [点我收藏+]

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 "$curloc\WADBs.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 "$curloc\WADBs.csv" -NoTypeInformation 

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

start-spassignment -global

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

 

Powershell 学习笔记【持续更新】

原文:http://www.cnblogs.com/cwyang/p/5069119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!