powershell Powershell脚本遍历提升列表中的所有项目,并替换图片和链接。这遍历了所有
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell Powershell脚本遍历提升列表中的所有项目,并替换图片和链接。这遍历了所有相关的知识,希望对你有一定的参考价值。
Add-PsSnapin Microsoft.SharePoint.PowerShell
$TopSiteUrl = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/KNP/Cells'
$CellImage = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/KNP/Cells/SiteAssets'
$topSite = Get-SPWeb $TopSiteUrl
foreach($s in $topSite.Webs)
{
$site = Get-SPweb $s.URL
$site.Name
$mList=$site.Lists["Linksb"]
$i = 0
while($i -le 5){
"-------------------------------------------"
$Item0 = $mList.Items[$i]
switch($Item0.DisplayName)
{
'Equipment Master List' {
$Itemx = $mList.Items[$i]
$Itemx['BackgroundImageLocation'] = $s.URL + '/SiteAssets/masterlist.jpg, Master List'
$Itemx["LinkLocation"] = $s.URL + '/Master List/Forms/AllItems.aspx, Master List'
$Itemx.Update()
}
'Facility Maps' {
$Item1 = $mList.Items[$i]
$Item1['BackgroundImageLocation'] = $s.URL + '/SiteAssets/FacilityMaps.jpg, Facility Maps'
$Item1["LinkLocation"] = $s.URL + '/Facility Maps/Forms/AllItems.aspx, Facility Maps'
$Item1.Update()
}
'Chemicals' {
$Item2 = $mList.Items[$i]
$Item2['BackgroundImageLocation'] = $s.URL + '/SiteAssets/Chemical.jpg, Chemicals'
$Item2["LinkLocation"] = $s.URL + '/Chemicals/Forms/AllItems.aspx, Chemicals'
$Item2.Update()
}
'JSA' {
$Item3 = $mList.Items[$i]
$Item3['BackgroundImageLocation'] = $s.URL + '/SiteAssets/jsa.jpg, JSA'
$Item3["LinkLocation"] = $s.URL + '/JSA/Forms/AllItems.aspx, JSA'
$Item3.Update()
}
'LOTO' {
$Item4 = $mList.Items[$i]
$Item4['BackgroundImageLocation'] = $s.URL + '/SiteAssets/loto.jpg, LOTO'
$Item4["LinkLocation"] = $s.URL + '/LOTO/Forms/AllItems.aspx, LOTO'
$Item4.Update()
}
}
$i++
}
}
Add-PsSnapin Microsoft.SharePoint.PowerShell
$TopSiteUrl = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/FMS/Cells'
$CellImage = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/FMS/Cells/SiteAssets'
$topSite = Get-SPWeb $TopSiteUrl
foreach($s in $topSite.Webs)
{
$site = Get-SPweb $s.URL
$site.Name
$mList=$site.Lists["Linksc"]
$Itemx = $mList.Items[0]
$Itemx['BackgroundImageLocation'] = $s.URL + '/SiteAssets/cells.png, Cells'
$Itemx["LinkLocation"] = $TopSiteUrl + ', Cells'
$Itemx.Update()
}
Add-PsSnapin Microsoft.SharePoint.PowerShell
$TopSiteUrl = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/InternationalSafety/Fibrelite2/Cells'
$CellImage = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/InternationalSafety/Fibrelite2/Cells/SiteAssets'
$topSite = Get-SPWeb $TopSiteUrl
foreach($s in $topSite.Webs)
{
$site = Get-SPweb $s.URL
$site.Name
$mList=$site.Lists["Linksb"]
$i = 0
while($i -le 5){
"-------------------------------------------"
$Item0 = $mList.Items[$i]
switch($Item0.DisplayName)
{
'Equipment Master List' {
$Itemx = $mList.Items[$i]
$Itemx['BackgroundImageLocation'] = $s.URL + '/SiteAssets/masterlist.jpg, Master List'
$Itemx["LinkLocation"] = $s.URL + '/Master List/Forms/AllItems.aspx, Master List'
$Itemx.Update()
}
'Facility Maps' {
$Item1 = $mList.Items[$i]
$Item1['BackgroundImageLocation'] = $s.URL + '/SiteAssets/FacilityMaps.jpg, Facility Maps'
$Item1["LinkLocation"] = $s.URL + '/Facility Maps/Forms/AllItems.aspx, Facility Maps'
$Item1.Update()
}
'Chemicals' {
$Item2 = $mList.Items[$i]
$Item2['BackgroundImageLocation'] = $s.URL + '/SiteAssets/Chemical.jpg, Chemicals'
$Item2["LinkLocation"] = $s.URL + '/Chemicals/Forms/AllItems.aspx, Chemicals'
$Item2.Update()
}
'JSA' {
$Item3 = $mList.Items[$i]
$Item3['BackgroundImageLocation'] = $s.URL + '/SiteAssets/jsa.jpg, JSA'
$Item3["LinkLocation"] = $s.URL + '/JSA/Forms/AllItems.aspx, JSA'
$Item3.Update()
}
'LOTO' {
$Item4 = $mList.Items[$i]
$Item4['BackgroundImageLocation'] = $s.URL + '/SiteAssets/loto.jpg, LOTO'
$Item4["LinkLocation"] = $s.URL + '/LOTO/Forms/AllItems.aspx, LOTO'
$Item4.Update()
}
}
$i++
}
}
Add-PsSnapin Microsoft.SharePoint.PowerShell
$TopSiteUrl = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/InternationalSafety/Fibrelite2/Cells'
$CellImage = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/InternationalSafety/Fibrelite2/Cells/SiteAssets'
$topSite = Get-SPWeb $TopSiteUrl
foreach($s in $topSite.Webs)
{
$site = Get-SPweb $s.URL
$site.Name
$mList=$site.Lists["Linksb"]
"-------------------------------------------"
$Item0 = $mList.Items[0]
$Item0['BackgroundImageLocation'] = $s.URL + '/SiteAssets/masterlist.jpg, Master List'
$Item0["LinkLocation"] = $s.URL + '/Master List/Forms/AllItems.aspx, Master List'
$Item0.Update()
"-------------------------------------------"
$Item1 = $mList.Items[1]
$Item1['BackgroundImageLocation'] = $s.URL + '/SiteAssets/FacilityMaps.jpg, Facility Maps'
$Item1["LinkLocation"] = $s.URL + '/Facility Maps/Forms/AllItems.aspx, Facility Maps'
$Item1.Update()
"-------------------------------------------"
$Item2 = $mList.Items[2]
$Item2['BackgroundImageLocation'] = $s.URL + '/SiteAssets/Chemical.jpg, Chemicals'
$Item2["LinkLocation"] = $s.URL + '/Chemicals/Forms/AllItems.aspx, Chemicals'
$Item2.Update()
"-------------------------------------------"
$Item3 = $mList.Items[3]
$Item3['BackgroundImageLocation'] = $s.URL + '/SiteAssets/jsa.jpg, JSA'
$Item3["LinkLocation"] = $s.URL + '/JSA/Forms/AllItems.aspx, JSA'
$Item3.Update()
"-------------------------------------------"
$Item4 = $mList.Items[4]
$Item4['BackgroundImageLocation'] = $s.URL + '/SiteAssets/loto.jpg, LOTO'
$Item4["LinkLocation"] = $s.URL + '/LOTO/Forms/AllItems.aspx, LOTO'
$Item4.Update()
}
以上是关于powershell Powershell脚本遍历提升列表中的所有项目,并替换图片和链接。这遍历了所有的主要内容,如果未能解决你的问题,请参考以下文章
用于在链接服务器上执行 DDL 语句的 Powershell 脚本 - 使用 SSIS 运行时不起作用
powershell SharePoint PowerShell遍历所有列表并将其作为列表模板备份。
如何从其他powershell脚本调用powershell脚本并且脚本是在powershell对象而不是文件中分配的
powershell [PS:脚本模板]只是PowerShell脚本要遵循的模板。 #PowerShell #Template