简体   繁体   English

使用Powershell连接到Microsoft Access DB / SharePoint列表

[英]Connect to Microsoft Access DB/SharePoint List with Powershell

I'm trying to connect to a Microsoft Access database, hosting a SharePoint List, with Powershell. 我正在尝试使用Powershell连接到承载SharePoint列表的Microsoft Access数据库。 However I can't seem to find accurate information online demonstrating how to do this. 但是,我似乎无法在网上找到准确的信息来演示如何执行此操作。 I'm relatively new to SharePoint but am comfortable with Powershell. 我对SharePoint比较陌生,但对Powershell感到满意。

The closest demonstration I've found is from the Microsoft Scripting Guys, in the first script on this page : 我找到的最接近的演示来自Microsoft脚本专家,在此页的第一个脚本中:

$path = "C:dataScriptingGuysHSG_8_10_09HighJumperDatabase.mdb"
$adOpenStatic = 3
$adLockOptimistic = 3

$cn = new-object -comobject ADODB.Connection
$rs = new-object -comobject ADODB.Recordset

$cn.Open("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path")
$rs.Open("SELECT TOP 1 [High Jumper Data].[Name], 
  [High Jumper Data].[Personal Best], [High Jumper Data].[Season Best] 
  FROM [High Jumper Data]
  ORDER BY [High Jumper Data].[Personal Best] 
  DESC , [High Jumper Data].[Season Best] DESC", 
  $cn, $adOpenStatic, $adLockOptimistic)

$rs.MoveFirst()
Write-host "The winner will likely be " $rs.Fields.Item("Name").Value

Unfortunately I've never used ADO, and am unsure of what the Provider parameter here is referring to. 不幸的是,我从未使用过ADO,并且不确定此处的Provider参数是指什么。

My objective is to query the SharePoint List for certain information, and then copy that information to another location. 我的目标是在SharePoint列表中查询某些信息,然后将该信息复制到另一个位置。 Are there comparable PowerShell objects/commands that replicate this script for this purpose? 是否有可比的PowerShell对象/命令为此目的复制了此脚本? Or do I need to learn ADO in order to access my SharePoint List on Access? 还是我需要学习ADO才能访问Access上的SharePoint列表?

The part "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path" is the connection string and consists of two parts, Provider and Data Source 部分"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path"是连接字符串,由两部分组成:Provider和数据源

The Provider parameter defines the technology, how to get data out of Access. Provider参数定义了技术以及如何从Access中获取数据。 In this case it is MS JET, see: 在这种情况下,它是MS JET,请参阅:

https://docs.microsoft.com/en-us/sql/ado/guide/appendixes/microsoft-ole-db-provider-for-microsoft-jet https://docs.microsoft.com/zh-cn/sql/ado/guide/appendixes/microsoft-ole-db-provider-for-microsoft-jet

The second part is where your source, the database is located. 第二部分是数据库的来源。 You need to set the location of your MS Access Database to the variable $path (first line) 您需要将MS Access数据库的位置设置为变量$path (第一行)

eg $path = "D:\\folder\\myAcessDB.mdb" 例如$path = "D:\\folder\\myAcessDB.mdb"

which used in the second part of the Connection String 在连接字符串的第二部分中使用的

"...DB.4.0;Data Source = **$path**"

Another way is using the powershell directly with sharpoint You could try this Blog post tutorial: 另一种方法是直接将Powershell与sharpoint结合使用。您可以尝试以下博客文章教程:

https://blogs.msdn.microsoft.com/besidethepoint/2012/02/08/better-sharepoint-lists-and-list-items-in-powershell/ https://blogs.msdn.microsoft.com/besidethepoint/2012/02/08/better-sharepoint-lists-and-list-items-in-powershell/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM