Error When Creating Links List Items (Hyperlinks)

In my case, I was using PowerShell to create a bunch of links to folders on a file-share in a SharePoint list. I came across errors when I used the 2010 method in 2013. Below I have provided examples of each method:

2010

$urlValue = New-Object Microsoft.SharePoint.SPFieldUrlValue("")
$urlValue.Description = "This is an awesome description"
$urlValue.Url =  "http://MyUrl.com"
$item["URL"] = $urlValue
$item.update()

2013

$newItem = $list.Items.Add()
$newItem["URL"] = "$urlString , $descriptionString"
$newItem["Comments"] = $descriptionString
$newItem.Update()

 

Advertisements

PowerShell scripts – Signing Error

Can’t Execute

If you attempt to execute a PowerShell script on the SharePoint server and  see : “Script cannot loaded.  The file is not digitally signed.  The script will not be executed on the system” or “… the execution of the script is disabled on the system…”

It means you either need to :

Sign the script OR

Set the PowerShell execution policy to allow you to execute unsigned scripts, e.g.

powershell.exe -executionpolicy bypass -file C:\script.ps1

Can’t Update

If you want to make changes to a PowerShell script but you are always prompted to save as a new version, the file may be locked. Right click the script file and select Properties. Ensure the Read-Only checkbox is unchecked. If there is a Unblock button next to the Read Only property, click Unblock.