Powershell脚本找不到URL

时间:2015-12-17 19:21:46

标签: powershell sharepoint

我有powershellworkflow开始SharePoint,但我的系统不允许我运行它。我得到的错误如下:

Get-SPWeb: Cannot find an SPWeb object with id or URL: xxx.com and site Url xxx.com
At C:\cert.ps1:1 char:17
+ $web = Get-SPWeb <<<< -Identity "xxx.com"
  + CategoryInfo  : InvalidData (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], SPCmdletPipeBindException
  + FullyQualifiedErrorId : Microsoft.SharePoint.Powershell.SPCmdletGetWeb

我尝试添加Add-PSSnapin Microsoft.Sharepoint.Powershell但是我收到错误,说它已经添加了。

这是脚本:

$web = Get-SPWeb -Identity "xxx.com" 
$manager = $web.Site.WorkFlowManager   
$list = $web.Lists["Certificate Tracking"]

$assoc = $list.WorkflowAssociations.GetAssociationByName("Certificate Notification","en-US")

$view = $list.Views["All Items"] #All Items
$items = $list.GetItems($view)  

$data = $assoc.AssociationData

foreach ($item in $items) {
 $wf = $manager.StartWorkFlow($item,$assoc,$data) 
}

$web.Dispose()

1 个答案:

答案 0 :(得分:1)

-Identity的{​​{1}}参数可以是完整路径或相对路径,也可以是带有通配符Get-SPWeb字符的路径。此外:

*

请尝试使用-Site参数,我认为这可能是您正在寻找的内容:

The identity param expects a valid URL in the form http://server_name or a relative path in the form of /SubSites/MySubSite.