سؤال

I'm trying to input some data in a Sharepoint lists, but the shell doesn't recognize the url for the Sharepoint app, although when I'm doing Get-SPWebApplication | Select Display Name, URL I'm able to see the instance I'm inputting.

This is the error I'm getting:

Error

This is the script I'm trying to execute:

#-------------------------------------------------------------------- 
# Name: Load CSV into SharePoint List 
# NOTE: No warranty is expressed or implied by this code – use it at your 
# own risk. If it doesn't work or breaks anything you are on your own 
#--------------------------------------------------------------------


# Setup the correct modules for SharePoint Manipulation 
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) 
{ 
   Add-PsSnapin Microsoft.SharePoint.PowerShell 
} 
$host.Runspace.ThreadOptions = "ReuseThread"

#Open SharePoint List 
$SPServer=http://win-pdp84ekkhr7/
$SPAppList="/Lists/Application List/" 
$spWeb = Get-SPWeb $SPServer 
$spData = $spWeb.GetList($SPAppList)

$InvFile="test.csv" 
# Get Data from Inventory CSV File 
$FileExists = (Test-Path $InvFile -PathType Leaf) 
if ($FileExists) { 
   "Loading $InvFile for processing..." 
   $tblData = Import-CSV $InvFile 
} else { 
   "$InvFile not found - stopping import!" 
   exit 
}

# Loop through Applications add each one to SharePoint

"Uploading data to SharePoint...."

foreach ($row in $tblData) 
{ 
   "Adding entry for "+$row."Application Name".ToString() 
   $spItem = $spData.AddItem() 
   $spItem["Application Name"] = $row."Application Name".ToString() 
   $spItem["Application Vendor"] = $row."Application Vendor".ToString() 
   $spItem["Application Version"] = $row."Application Version".ToString() 
   $spItem["Install Count"] = $row."Install Count".ToString() 
   $spItem.Update() 
}

"---------------" 
"Upload Complete"

$spWeb.Dispose()

I don't know if I need to configure some permissions.

هل كانت مفيدة؟

المحلول

You need to wrap the url within double quotes so that PowerShell treats it as a string instead of as a command.

$SPServer= "http://win-pdp84ekkhr7/"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top