I want to add a item to a SharePoint 2010 list by using PowerShell.
This list is related with the standard SharePoint Approval Workflow.
I want to add Items and set the workflow status to “Published” with PowerShell.
My Code, but how it is possible to set the Workflow status to “Published”?
$web = Get-SPWeb $Url
$list = $web.Lists["MyList"]
$newitem = $Schulliste.items.Add()
$newitem["Column1"] = "Test1" # Works fine!
#Set Column Writable
$column = $list.Fields["WorkflowName"]
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.Update()
#Update Workflow Item
$newitem["WorkflowName"] = "Published" #Not working
$newitem.update()
#Set Column Readonly
$column = $list.Fields["WorkflowName"]
$column.Hidden = $true
$column.ReadOnlyField = $true
$column.Update()
My workaround now is to activate and deactivate the content approval