【问题标题】:Connect to Microsoft Access DB/SharePoint List with Powershell使用 Powershell 连接到 Microsoft Access DB/SharePoint 列表
【发布时间】:2018-04-10 20:52:56
【问题描述】:

我正在尝试使用 Powershell 连接到托管 SharePoint 列表的 Microsoft Access 数据库。但是,我似乎无法在网上找到准确的信息来演示如何执行此操作。我对 SharePoint 比较陌生,但对 Powershell 很熟悉。

我发现的最接近的演示来自 Microsoft Scripting Guys,在 this page 的第一个脚本中:

$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

不幸的是,我从未使用过 ADO,并且不确定这里的 Provider 参数指的是什么。

我的目标是查询 SharePoint 列表以获取某些信息,然后将该信息复制到另一个位置。是否有类似的 PowerShell 对象/命令可以为此目的复制此脚本?或者我是否需要学习 ADO 才能访问我的 SharePoint 访问列表?

【问题讨论】:

    标签: powershell ms-access sharepoint ado


    【解决方案1】:

    "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = $path"部分是连接字符串,由Provider和Data Source两部分组成

    Provider 参数定义了技术,如何从 Access 中获取数据。在这种情况下,它是 MS JET,请参阅:

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

    第二部分是您的源数据库所在的位置。您需要将 MS Access 数据库的位置设置为变量 $path(第一行)

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

    用于连接字符串的第二部分

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

    另一种方法是直接使用带有 sharpoint 的 powershell 你可以试试这个博客文章教程:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      • 2019-02-27
      • 1970-01-01
      相关资源
      最近更新 更多