使用批处理文件或 Powershell 访问测试 SharePoint URL?

Access test SharePoint URL with Batch file or Powershell?

我正在尝试弄清楚如何使用一些简单的东西来测试对 SharePoint URL 的访问,而无需安装任何额外的东西。普通win10环境,没有管理员权限。我有一些代码经验,但不是最近。

我所拥有的内容的简短片段..:

:MENU
ECHO Text text text 
ECHO Menu with about 10 selections
SET /P M=Here you chose from different AD-testusers:

IF %M%==1 SET title=testuser1
IF %M%==1 GOTO A

:A
Runas /savecred /user:my_domain\some_user "C:\Program Files\internet explorer\iexplore.exe http://test_URL/"
ECHO %USERDOMAIN%\%USERNAME% login %title% @ %DATE%,%TIME% >> log\log%DATE%.txt
GOTO MENU

这在某些情况下还可以,但仍然需要手动检查结果。该日志文本输出不是很重要,但我想包含一些有关用户是否有权访问该特定 SharePoint 页面的信息。可能吗?

您可以使用 powershell 检查 url returns 代码是否为 200(加载成功)

reference to this article

来自link ive shared,编辑以下内容

试试这个?

替换

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>$req= [system.Net.WebRequest]::Create($objItem)

通过

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre><code>    $username = "accountname"
    $pwd = "accountnamePassword"
    $domain = "mydomain"
    $req = [system.Net.WebRequest]::Create($url)
    $req.Credentials = new NetworkCredential($username, $pwd, $domain);