使用Powershell更新Resources中的Base Calendar属性 [英] Updating Base Calendar property in Resources using Powershell

查看:72
本文介绍了使用Powershell更新Resources中的Base Calendar属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用powershell批量修改参考资料中的基本日历属性,为此我编写了一个脚本,但是直到现在它还没有工作,我无法解决它,这就是为什么我想问你的人,知道的人。

Hello, I'm trying to modify in bulk the base calendar property in Resources using powershell, to do that I write a script, but until now it is not working and I have no clue to solve it, that is why I like to ask to you, the people that know.

我的脚本如下,很简单我有一个带有资源ID($ Resource.RES_UID)的CSV文件日历索引($ Resource.Calendar,它指向Project Server列表日历中的正确日历):

My Script is the following, it is simple I have a CSV file with the Resource ID ($Resource.RES_UID) and a calendar index ($Resource.Calendar, it point to the right calendar in the list calendars on the Project Server):

$ pwaUrl =" http:// server / pwa"

$ PSsvcUrl = $ pwaUrl +" / _ vti_bin / PSI / Resource.asmx?wsdl" 

$ PSsvcUrlCal = $ pwaUrl +" / _ vti_bin / PSI / Calendar.asmx?wsdl" 

$ c = Get-Credential

$ svcPSProxy = New-WebServiceProxy -uri $ PSsvcUrl -credential $ c 

$ svcPSProxyCal = New-WebServiceProxy -uri $ PSsvcUrlCal -credential $ c 

#$ svcPSProxy。 ReadUserList(" ALL")。资源| Export-CSV Resources.txt -Delimiter" |"

$ users = Import-Csv -delimiter';''Resources_cal.csv'

$ calendars = $ svcPSProxyCal .ListCalendars()。日历



函数Set-Calendar {
$
param($ Resource)

    $ ResourceID = $ Resource.RES_UID

    $ calendar = $ Resource.Calendar



    $ dsResource = $ svcPSProxy.ReadResource($ ResourceID)

    $ svcPSProxy.CheckoutResources($ ResourceID)> $ null

$pwaUrl = "http://server/pwa"
$PSsvcUrl = $pwaUrl + "/_vti_bin/PSI/Resource.asmx?wsdl" 
$PSsvcUrlCal = $pwaUrl + "/_vti_bin/PSI/Calendar.asmx?wsdl" 
$c = Get-Credential
$svcPSProxy = New-WebServiceProxy -uri $PSsvcUrl -credential $c 
$svcPSProxyCal = New-WebServiceProxy -uri $PSsvcUrlCal -credential $c 
#$svcPSProxy.ReadUserList("ALL").Resources | Export-CSV Resources.txt -Delimiter "|"
$users = Import-Csv -delimiter ';' 'Resources_cal.csv'
$calendars = $svcPSProxyCal.ListCalendars().Calendars

function Set-Calendar{
param( $Resource )
    $ResourceID = $Resource.RES_UID
    $calendar = $Resource.Calendar

    $dsResource = $svcPSProxy.ReadResource($ResourceID)
    $svcPSProxy.CheckoutResources($ResourceID) > $null

    $ dsResource.Resource.BaseCalendarUniqueId = $ calendars [$ calendar] .CAL_UID



    $ svcPSProxy.UpdateResources($ dsResource,$ false,$ true)> $ null



    $ svcPSProxy.CheckInResources($ resourceObj,$ false)> $ null



}


$
foreach($ usr in $ users){

    if($ usr.res_type -eq 2){

       设置日历$ usr

    }
}

    $dsResource.Resource.BaseCalendarUniqueId = $calendars[$calendar].CAL_UID

    $svcPSProxy.UpdateResources($dsResource, $false, $true) > $null

    $svcPSProxy.CheckInResources($resourceObj, $false) > $null

}

foreach($usr in $users){
    if ($usr.res_type -eq 2){
        Set-Calendar $usr
    }
}

>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

我遇到以下错误:

在此对象上找不到属性'BaseCalendarUniqueId';确保它存在且可设置。

在C:\Datos \ Project Server 2010 \ Set-Resource-Calendar.ps1:19 char:26

+ &NBSP; &NBSP; $ dsResource.Resource。 <<<< BaseCalendarUniqueId = $ calendars [$ calendar] .CAL_UID

  &NBSP; + CategoryInfo  &NBSP; &NBSP; &NBSP;  :InvalidOperation:(BaseCalendarUniqueId:String)[],RuntimeException

  &NBSP; + FullyQualifiedErrorId:PropertyNotFound

Property 'BaseCalendarUniqueId' cannot be found on this object; make sure it exists and is settable.
At C:\Datos\Project Server 2010\Set-Resource-Calendar.ps1:19 char:26
+     $dsResource.Resource. <<<< BaseCalendarUniqueId = $calendars[$calendar].CAL_UID
    + CategoryInfo          : InvalidOperation: (BaseCalendarUniqueId:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

但是我也不会尝试CheckIn的工作原理,也就是欢迎任何线索。

But I never try if the CheckIn works also, that is any clue will be welcome.

提前感谢您的帮助。

问候

推荐答案

你好,我继续研究,我找到了这个页面:

Hello, I continued researching and I found this page:

  &NBSP; &NBSP; http://msdn.microsoft.com/en-us/library/ee767706.aspx

      http://msdn.microsoft.com/en-us/library/ee767706.aspx

阅读此PSI信息页面,关于"PSI做什么和不做什么",我意识到也许我想要修改是不可能的,因为以下关于"PSI不做什么"的段落,关于编辑资源日历是不允许的,
而我正在尝试更改基本日历对于资源,我想。如果有人可以确认或否认,我将不胜感激。

Reading this PSI information page about "What the PSI does and does not do", I realize that maybe that I'm trying to modify is not possible because of the following paragraph about "What the PSI does not do", about Editing resource Calendar is not allowed, and I'm trying to change the base calendar for the resource, I suppose. If anyone can confirm or denied that, I will be grateful.

谢谢

资源

Resources





  • 请求或执行资源调配。

  • Requesting or performing resource leveling.


更改作业的资源。 (您可以使用PSI删除作业并创建一个新作业。)

Changing the resource on an assignment. (You can use the PSI to delete the assignment and create a new one.)


删除或替换已接受实际工作的资源(实际值)。

Deleting or replacing a resource that has actual work accepted (actuals).


在工作之间更改资源类型,材料和成本。

Changing a resource type between work, material, and cost.


创建或编辑资源日历。


添加资源时对于任务,PSI不会像Project Professional那样自动重新分配工作。开发人员可以选择并明确设置工作分配。

When adding a resource to a task, the PSI does not automatically redistribute work the way Project Professional does. It is up to the developer to choose and explicitly set the work distribution on the assignments.


这篇关于使用Powershell更新Resources中的Base Calendar属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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