SharePoint Powershell Script
来源:互联网 发布:学生档案表sql查询 编辑:程序博客网 时间:2024/06/09 09:05
最近在做SharePoint 2010,对SharePoint PowerShell脚本有了一点理解。
SharePoint PowerShell的命令格式如下:verb-noun,例如:Get-SPSite,通过SPSite -?获得SP-Site有关的命令。按F7键获得最近运行的命令。在PowerShell中的变量就是用$来创建,不需要像Java和C#那样先声名。
PowerShell中常用比较操作符:-lt 小于,-le 小于或等于,-gt 大于, -ge大于或等于,-eq 等于,-ne 不等于, -like 相似,支持通配符,-nolike 不相似,支持通配符。
下面这段Script就是将c:\UserProfile.csv中的所有User信息添加到SharePoint List中。
#Add-PSSnapin Microsoft.SharePoint.PowerShell
$site=Get-SPSite "http://prsgi0001:1414"
$web=$site.RootWeb
$list=$web.Lists["UserProfile"]
$userlist=import-csv -Path C:\UserProfile.csv
for($count=0;$count -lt $userlist.count;$count++)
{
$listitem=$list.Items.Add()
$listitem["Title"]=$userlist[$count].UserID
$listitem["FirstName"]=$userlist[$count].FirstName
$listitem["LastName"]=$userlist[$count].LastName
$listitem["ChineseName"]=$userlist[$count].ChineseName
$listitem.Update()
write-host $userlist[$count].UserID
write-host $userlist[$count].FirstName
write-host $userlist[$count].LastName
write-host $userlist[$count].ChineseName
}
write-host "success"
同时可以通过DOS的批处理文件bat来调用script1.ps1的脚本。调用如下:
invoke.bat:
powershell.exe -command %~dp0script2.ps1 -path %~dp0 -abc 'abc1234'
Pause
script1.ps1:
param([string]$path,[string]$abc)
上面这句话变量$path用于获取bat中powershell.exe传来的%~dp0,$abc获取'abc1234'。
- SharePoint Powershell Script
- SharePoint 2010 Cookbook: Backup a Site Collection Automatically with a PowerShell Script
- Powershell Database Backup Script
- SharePoint PowerShell Create Site
- SharePoint 2010 PowerShell 命令
- SharePoint 数据库管理-PowerShell
- SharePoint 网站管理-PowerShell
- SharePoint 内容部署-PowerShell
- SharePoint 企业搜索-PowerShell
- SharePoint Foundation 搜索-PowerShell
- SharePoint Excel Service-PowerShell
- SharePoint PerformancePoint Service-PowerShell
- SharePoint Access Service-PowerShell
- SharePoint Solutions Deployment-PowerShell
- SharePoint Word Service-PowerShell
- SharePoint 2010 PowerShell 系列
- Powershell配置SharePoint环境
- Powershell管理SharePoint站点
- 云计算体系架构研究
- iOS 开发,工程中混合使用 ARC 和非ARC
- armeabi 和armeabi-v7a文件夹的区别
- Codeforces_392B_Tower of Hanoi(记忆化搜索)
- STL 容器
- SharePoint Powershell Script
- 6174
- Windows 中不规则窗体的编程实现
- 2.java里,试做了华氏摄氏度和摄氏度之间的经典案例
- JavaAPI
- VS快捷键解决方法
- 我草,坚持不下去了啊!!!
- 2.25周二 离散,概率
- eclipse中设置tomcate 内存不溢出