如何在Windows PowerShell脚本中将凭据应用于Sharepoint URL [英] How to apply credentials to Sharepoint url in windows powershell script

查看:113
本文介绍了如何在Windows PowerShell脚本中将凭据应用于Sharepoint URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过Powershell应用sharepoint url凭证来访问网站?

i必须在代码中应用用户名和密码。我如何申请?

How could i apply sharepoint url credential to access the website by Powershell?
i have to apply username and password in the code.How could I apply?

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) 
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$sourceWebURL = "http://sezmnc22787"
$sourceListName = "DL_Accounts"
$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]
If(!($spSourceList  -eq $null)){
$spSourceItems = $spSourceList.GetItems()
$spSourceItems | ForEach-Object {
$Username=$_['AccountName']
$Username=$Username.Substring($Username.IndexOf("#")+1)
$Group = [ADSI]"LDAP://CN=CMIT, CN=Users, DC=env, DC=com"
$User = [ADSI]"LDAP://CN=$Username, CN=Users, DC=env, DC=com"
If ($Group.IsMember($User.ADsPath) -eq $False)
{
    $Group.Add($User.ADsPath)
}
}
}

推荐答案

_。名称-eq Microsoft.SharePoint.PowerShell})-eq
_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq


null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
null) { Add-PSSnapin Microsoft.SharePoint.PowerShell; }


sourceWebURL = http:// sezmnc22787
sourceWebURL = "http://sezmnc22787"


这篇关于如何在Windows PowerShell脚本中将凭据应用于Sharepoint URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆