添加类型-路径'C:\ Users \ klkc510 \ Downloads \ DeleteResources \ bin \ Microsoft.ProjectServer.Client.dll' 添加类型-Path'C:\ Users \ klkc510 \ Downloads \ DeleteResources \ bin \ Microsoft.SharePoint.Client.Runtime.dll' 添加类型-Path'C:\ Users \ klkc510 \ Downloads \ DeleteResources \ bin \ Microsoft.SharePoint.Client.dll'
$ pwaPath =“” $ projContext =新对象Microsoft.ProjectServer.Client.ProjectContext($ pwapath) $ UserName =“” $ Password =“”
$ credentials =新对象Microsoft.SharePoint.Client.SharePointOnlineCredentials($ UserName,(ConvertTo-SecureString $ Password -AsPlainText -Force))
$ projContext.Credentials = $ credentials
$projContext.Load($projContext.EnterpriseResources)
$projContext.ExecuteQuery()
$erp = $projContext.EnterpriseResources
$enterprise_resourceid = [Guid]::NewGuid()
$resname = "Test"
$body = {parameters:{'Id:$enterprise_resourceid"",Name:$resname}}
$erp.Add.$body
Write-Host("Deleted Resource: " + $body.Id)
$erp.Update()
$projContext.ExecuteQuery()
$projContext.Load($projContext.EnterpriseResources)