0

I have a powershell that kicks off a workflow in SharePoint but my system is not allowing me to run it. The error I'm getting is as follows:

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

I tried adding Add-PSSnapin Microsoft.Sharepoint.Powershell but I the get an error saying its already been added.

Here's the script:

$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 Answer 1

1

The -Identity parameter for Get-SPWeb can be either a full or relative path, or a path with a wildcard * character. Additionally:

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

Try this instead using the -Site param, which I think might be what you're looking for:

Get-SPWeb -Site http://sitename/sites/site1
Sign up to request clarification or add additional context in comments.

1 Comment

I hate Microsoft...I changed it to Site and it got rid of the error but couldn't initialize the variables. I changed it back to Identity and it worked. Go figure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.