Update person/group field in powershell, with a group name
Hi,
I need to update a person column in my library through powershell, I can do this for a single user, but how do update the value to be a sharepoint group? the column has been set correctly to allow groups, and I can set the group name if I use the browser.
but I cant do it through powershell. I get "Invalid data has been used to update the list item"
Thanks,
Hi Craig,
It seems you are trying to assign Role into people and group column. That's why it is throwing error. Try assigning group into that column.
$web = get-spweb https://mysite/myweb
$groups = $web.Groups
$GroupName = $groups["GroupName"]
foreach($list in $web.Lists)
if($list.BaseType -eq "DocumentLibrary")
$items = $list.Items
foreach ($item in $items)
if($item.File.CheckOutType -eq "None"){
$item.File.CheckOut()
$item["Document Advisor"]= $GroupName
$item.Update()
$item.File.CheckIn("Admin")
Write-Host "updating document: "$item["Title"]
I've tried to modify your code please check it.
Hope this will help to resolve your problem.
Best Regards,
Brij K
Similar Messages
-
Updating vs. Deleting Folder files with the same name
Hello all,
Bear with me as I try to explain this.
First off, I'm a long time Windows user who just happily converted to Mac. I'm loving my mac so far, but I've run into a snag that I hope to get clarification on.
Let me set up a scenario on how this works with Windows.
Let's say I have two folders/root directories labeled as today's date "20100729" with image files in them. Each folder has different picture file names. In other words, the files in each of folders are different. The only thing that is the same is the Folder/Directory name, which in this case is "20100729".
So, in a windows environment let's say that each of these folders (with the same name) are located on 2 hard drives (A & B). If I take the folder from drive "A" and drop it in drive "B", windows seamlessly combines the files from both folders into one.
On the flip side, when doing the same thing on my Mac, the entire folder contents from drive B gets replaced from drive A, even though the file names are all different. Which is very annoying.
If you understand what I'm saying and know of a way for this to work the "Windows" way please let me know.
Thanks in advance for your help. Let me know if you need further clarification.
Cheers,
- JeffUse the ditto command in the Terminal, which is in the /Applications/Utilities/ folder; for instructions on its use, enter 'man ditto' without the quote marks into the Terminal prompt.
(53065) -
Update duplicate records in pl/sql with each different name
this is my table newemp
EMPNO ENAME JOB
7000 ELLISON OWNER
7369 SMITH CLERK
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
EMPNO ENAME JOB
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERKI WANT TO UPDATE ALL THOSE REPEATING JOBS
E.G IF THERE ARE FOUR SALESMAN IT SHOULD BE LIKE DIS SALE4,SALE5,SALE6,SALE7,SALE8. AND 2 ANALYST = ANA2,ANA3
AND IF THE RECORD IS ONLY ONCE THN NO CHANGE.
I DID THIS BY USING STORED PROCEDURE FOR EACH DISTINCT SALE BUT I WANT TO DO IN A SINGLE PROCEDURE
THE STORED PROCEDURE THAT I HAVE DEVELOPED ID LIKE THIS:-
create or replace procedure sp_duptest
is
x number(20);
y number(3);
j Number := 0;
cursor z is select empno from newemp where job = 'CLERK';
begin
select empno
into x
from newemp where job = 'CLERK' ;
exception
when no_data_found then
null;
when too_many_rows then
begin
select count(job) into y from newemp where job='CLERK';
y := y-1;
for i in z
loop
y := y+ 1;
if y>1 then
update newemp
set job = 'CLE'||y
where empno = i.empno;
else
update newemp set job ='clerk';
end loop;
commit;
end;
end;Edited by: BluShadow on 02-Aug-2011 10:48
added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself.
Edited by: Aviral on Aug 2, 2011 2:50 AMSomething like this perhaps?
SQL> create table emp2 as select * from emp;
Table created.
SQL> ed
Wrote file afiedt.buf
1 update emp2 set job = (select job
2 from (select empno
3 ,substr(job,1,5)||to_char(row_number() over (partition by job order by empno),'fm09') as job
4 from emp2) t
5* where t.empno = emp2.empno)
SQL> /
14 rows updated.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK01 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALES01 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALES02 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAG01 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALES03 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAG02 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAG03 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALY01 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESI01 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALES04 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK02 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK03 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALY02 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK04 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> -
How to modify person or group field value with new value
Hi
I have person or group field having property Person Only.
Thsi firls already have one value. Now I want to update it but this code to update value is not working.
string myName = @"ABC\myname";
web.EnsureUser(myName);
SPUser myUser = web.SiteUsers[myName];
SPFieldUserValue myNamevlaue = new SPFieldUserValue(web, myUser.ID, myUser.LoginName);
oSplistItem["My_x0020_User"] = myNamevalue;
oSplistItem.Update();
I am getting myNamevalue correct in the veriable. But why its not updating in the list?
is there any issue in the above code?
Do I need to delete previous value and then update new value in this field? How?Hi,
The format of the user value in people/Group field must be
ID;#Name, you can use the following code snippets to update the people/group field.
string loginName = "ABC\\myname";
SPUser user = web.SiteUsers[loginName];
SPList list = web.Lists.TryGetList("ListName");
if (list == null)
Console.WriteLine("list is not exist!");
return;
SPListItem item = list.GetItemById(3);
item["My_x0020_User"] = user.ID.ToString() + ";#" + user.Name;
item.Update();
Thanks,
Jason
Please remember to mark the reply as answer if it help, and unmark the answer if it provide no help. -
How to update person or group column with peopleeditor control values
Hi,
I have created custom aspx page and added "PeopleEditor" control(can select multiple users) in that page. Now I am trying to update person or group column with peopleeditor control values.I am not getting any error if I select single user
in PeopleEditor control but getting error if I select more than one user.
UpdateItem(listItem, "ListColumnName",
listItem.ParentList.ParentWeb.EnsureUser(peopleeditorId.CommaSeparatedAccounts));
Can anybody help me out to resolve the issue?
Thank you in advance!!!
AA.First get all the users/groups from the PeapleEditor by using PeapleEditor.ResolvedEntities
foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
SPPrincipalType principalType = (SPPrincipalType)Enum.Parse(typeof(SPPrincipalType), pickerEntity.EntityData["PrincipalType"].ToString());
if (principalType == SPPrincipalType.User || principalType == SPPrincipalType.SecurityGroup)
string loginName = pickerEntity.Key;
//your code here
else if (principalType == SPPrincipalType.SharePointGroup)
string groupName = pickerEntity.Key;
//your code here
Add all the users/groups in an instance of SPFieldUserValueCollection
and then update your list item.
SPFieldUserValueCollection users = new SPFieldUserValueCollection();
users.Add(new SPFieldUserValue(web,user.ID,user.Name));
item["YourUserColumn"] = users;
item.Update(); -
My Active Directory environment is 2003 functional level and we have Exchange 2010.
I am trying to find out the best way to do a mass edit for the "Managed by" values of our security and distribution groups.
I know we can export the "managed by" field by csvde but I am not sure this is the correct way to do it. Also in the case that there are multiple users assigned to be managing a distribution group it only shows one value. Also powershell from Exchange
2010 can be used with "get-distribution" but as our AD environment is 2003 is this correct also?
Finally once the data is exported to csv can it be edited to then reimport and udpate the existing group managed by fields with new values?
Not really sure that the best way to go about this is.
Summary - We have 2003 AD with Exchange 2010 and I am trying to export a list of all our Distribution/Security groups showing the group name and managedby values so we can edit and update the
existing managedby values with new ones. In some cases we have multiple users as the owners.
Appreciate any advice on how this can be best achieved. Thank you.Hi,
We can use the following command in Exchange 2010 to export "Managed by" field of Distribution and Security groups:
Get-DistributionGroup | Select-object Name,@{label="ManagedBy";expression={[string]::join(“;”,$_.managedby)}},Primarysmtpaddress | Export-Csv
C:\export.csv
After you changed the Managed by field in export.csv and saved it as a new file named import.csv, we can run the following command to set with new value:
Import-Csv C:\import.csv | Foreach-Object{ Set-DistributionGroup –Identity $_.Name –ManagedBy $_.ManagedBy}
Hope it works.
Thanks,
Winnie Liang
TechNet Community Support -
How to Insert Sharepoint 2013 Person or Group Field using VBA
Hello,
How to Insert Sharepoint 2013 Person or Group Field using VBA , I tried set the field with ID / ID;Name / Name
but all failed, Please advice
Function SetSP_Field(F_Yer As Single, F_WekNo As Single, F_ProjectNum As String, strField As Variant, strFieldValue As Variant) As String
' test code
Dim rst As Recordset
Dim strSQL As String
Dim SP_RecSet As ADODB.Recordset
Set SP_RecSet = New ADODB.Recordset
SetSP_Field = False
strSQL = "Status Report"
On Error Resume Next
Call SP_Connect(2)
strSQL = "select " & SP_List & ".* From " & SP_List _
& " Where [Year] = " & CInt(F_Yer) _
& " and [WeekNo] = " & CInt(F_WekNo) _
& " and [Compass_Code] = '" & F_ProjectNum & "' ; " _
' & " Set " & strField & " = " & strFieldValue
'Debug.Print strSQL
'Debug.Print SP_CN
SP_RecSet.Open strSQL, SP_CN, adOpenStatic, adLockOptimistic
If SP_RecSet.RecordCount = 0 Then
Debug.Print "Record for project: " & F_ProjectNum & " not found"
LogFile.WriteLine ("Record " & strID & " not found")
End If
If Not SP_RecSet.EOF Then
'SP_RecSet.Edit
SP_RecSet.Fields(strField) = strFieldValue
SP_RecSet.Update
If Err.Number <> 0 Then
MsgBox ("SP Update Error: " & Err.Description)
GoTo Exit_Fun
End If
SetSP_Field = True
End If
Exit_Fun:
SP_RecSet.Close
Set SP_RecSet = Nothing
End FunctionHi Tim,
Let’s verify the followings:
Whether this issue occurred for other lists in the same site.
Whether this issue occurred for all users who don’t have full control.
Whether this issue occurred on other sites.
When you created the people & group column, which show field did you used? Please try to use a different show field for the people & group column, compare the result.
In addition, please check if the link is useful:
http://www.learningsharepoint.com/2013/08/21/empty-value-in-people-picker-after-saving-the-list-form-in-sharepoint/
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
How to update a People and group field using a sandbox solution
Hi,
I am creating a sandbox solution for office 365 and creating a custom form using visual web part, which will allow users to enter data in a custom list.
And that list also have a user field. I am able to get SharePoint user field on the form (using javascript) which is searching for the user and get a value (working fine).
Issue: But I am not able to save the user value. Because to save user value I require web, UserID and login name, to construct SPFieldUserValue object or string in "111;#TestUser" format. Moreover that user should be present in
SiteUserInfoList.
I tried web.EnsureUser() but did not work under sanbox solution.
Can you please provide any pointer or workaround to the problem? I may be missing something here.
Thanks,
HimanshuHi,
According to your description, my understanding is that you want to update the people and group field in Sandbox solution.
In the sandbox solution, you can still use the web.EnsureUser() function to get the user information, see the thread below:
EnsureUser in sandboxed solution
In additional, there is a demo with your similiar requirement for your reference:
Using the People Picker Control in Sandbox Solutions / Office 365
Thanks
Best Regards,
Jerry Guo
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Copy person & group field value to another person or group field programmatically
Hi
I have one user list in SharePoint sitecollection1 having User in Title(having simple user name) and UserName in Person or Group type field.
I want to copy this list into my site list with same column names programatically using timer job.
How I can copy the person or Group field from siteColletion1 to person or group field of sitecollection2(my site),
as both column types are same.
Pleas suggest any solution.I am getting user name and user id using following code,
foreach (Microsoft.SharePoint.Client.FieldUserValue userValue in oclistItem["UserName"] as Microsoft.SharePoint.Client.FieldUserValue[])
string username = userValue.lookupValue.tostring();
But how to get the login name ? or how can I get the User Object from this field?
Anybody got this type of issue before.
Please suggest any solution -
Modifying a Software Update Group Deployment via PowerShell
Good Morning Guys -
Recently, I created numerous Software Update Group (SUG) advertisements to a variety of collections using a PowerSHell script I wrote. It used the cmdlet "Set-CMSoftwareUpdateDeployment" which is described by Microsoft as "Modifies a
software update deployment in Configuration Manager." Below is the command I used for the advertisement I'm using as an example here:
Start-CMSoftwareUpdateDeployment -SoftwareUpdateGroupName "Workstation Related - Mar 2014 Deployment" -CollectionName "Workstation Patch Management - Window #5 - 3rd Monday - Auto Restart" -DeploymentName "Workstation Patch Management - Window #5 - 3rd Monday - Auto Restart" -DeploymentType Required -VerbosityLevel OnlySuccessAndErrorMessages -TimeBasedOn UTC -DeploymentAvailableDay 2014/3/17 -DeploymentAvailableTime 5:00 -DeploymentExpireDay 2014/3/17 -DeploymentExpireTime 5:00 -UserNotification DisplaySoftwareCenterOnly -SoftwareInstallation $False -AllowRestart $False -RestartServer $False -RestartWorkstation $False -ProtectedType NoInstall -UnprotectedType NoInstall
What I'm needing to do, though, is change many of these advertisements from "Required" to "Available" using PowerSHell again. Since it's described as "modifies," I assumed that I could run the exact same line used to create
the advertisement, except only change the "Required" string to "Available." The advertisement name is the same, so I thought it would work.
When I ran it, it simply created another advertisement with the same name:
Am I doing something incorrectly when trying to modify the advertisement or is what I've trying to do even possible with this cmdlet? If not possible, any suggestions you have as to how I could do what I'm trying to do on a large scale would be appreciated!
Thanks!
Ben K.I just tried on a required deployment:
set-cmsoftwareupdatedeployment -softwareupdategroupname "My Group Name" -deploymentname "My deploymentname" -collectionname "my collection name" -deploymenttype "available"
And it changed to Available. Not sure why that isn't working for you. -
How to update a custom field in declarative workflow with VS 2013
Hello,
How to update a custom field in declarative workflow with VS 2013
any help would be appreciated!!!!!
Thanks regards, Vignesh.Dear all,
I'm using 4.6C right now, i already implement BADI MEREQ001, but this only valid
for creating PR via ME51N.
I found an EXIT_SAPLEBND_001 and tried to implement it,
but i got another difficulties since how i transfer CEBAN structure to EBAN structure.
thanks very much.
Regards,
Billy -
Hi All,
I'm getting this exception "The SPListItem being updated was not retrieved with all taxonomy fields." when i try to programatically update a taxonomy field of a list item. Can any1 pls tell me why this exception occurs ???Recently hit this myself, as well. Turns out it's a central admin setting that throttles the lookup return count, and Taxonomy fields are just lookups under the hood.
Go into Central Administration, Manage Web Applications, select your web application, and then in the ribbon choose the dropdown under General Settings select Resource Throttling. Find the setting for "List View Lookup Threshold" and raise
it from the default 8 (can go up to 1000, but 20 is likely fine depending how many lookup fields you're pulling back in your SPListItem). -
Problem with update of BLOB field in a table with compound primary key
Hi,
I've been developing an application in Application Express 3.1.2.00.02 that includes processing of BLOB data in one of the tables (ZPRAVA). Unfortunately, I've come across a strange behaviour when I tried to update value in a BLOB field for an existing record via a DML form process. Insert of a new record including the BLOB value is OK (the binary file uploads upon submiting the form without any problems). I haven't changed the DML process in any way. The form update process used to work perfectly before I'd included the BLOB field. Since than, I keep on getting this error when trying to update the BLOB field:
ORA-20505: Error in DML: p_rowid=3, p_alt_rowid=ID, p_rowid2=CZ000001, p_alt_rowid2=PR_ID. ORA-01008: not all variables bound
Unable to process row of table ZPRAVA.
OK
Some time ago, I've already created another application where I used similar form that operated on a BLOB field without problems. The only, but maybe very important, difference between both the cases is that the first sucessfull one is based on a table with a standard one-column primary key whereas the second (problematic one) uses a table with compound (composite) two-column PK (two varchar2 fields: ID, PR_ID).
In both cases, I've followed this tutorial: [http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm]).
Can anybody confirm my suspicion that Automatic Row Processing (DML) can be used for updating BLOB fields within tables with only single-column primary keys?
Thanks in advance.
ZdenekIs there a chance that the bug will be included in the next patch?No, this fix will be in the next full version, 3.2.
Scott -
Updating the Assignment Field (ZUONR) with Check No
Hi
Can anyone help me please?
I would like to update the assignment field (ZUONR) in the Bank Payables Clearing Account with the cheque number from the payment run (PAYR-CHECF).
1. Firstly is this possible?; and
2. If so could you explain how I do this.
Thanks in advance for your assistance on this issue.
Regards
ClaireHi
I would but there is no sort key which contains this, nor can I create one :o(.
If you are aware of how I can do this then please let me know. Is there a user exit which will populate this field when a payment has been made?
Regards
Claire -
hi friends
i am trying to set peoples or groups field in sharepoint list form with current user login name
here my code
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
$(document).ready(function NewItemView () {
var currentUser;
if (SP.ClientContext != null) {
SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
else {
SP.SOD.executeFunc('sp.js', null, getCurrentUser);
function getCurrentUser() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
function onSuccessMethod(sender, args) {
var account = currentUser.get_loginName();
var accountEmail = currentUser.get_email();
var currentUserAccount = account.substring(account.indexOf("|") + 1);
SetAndResolvePeoplePicker("requester",account);
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
function SetAndResolvePeoplePicker(fieldName, userAccountName) {
var controlName = fieldName;
var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
peoplePickerEditor.val(userAccountName);
spPeoplePicker.AddUnresolvedUserFromEditor(true);
</script>
but it is not working
please help meHi,
According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
To set "peoples or groups" field with current user "login name”, you can use the below code:
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
<script type="text/javascript">
function SetPickerValue(pickerid, key, dispval) {
var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
xml = xml + PreparePickerEntityXml(key, dispval);
xml = xml + '</Entities>';
EntityEditorCallback(xml, pickerid, true);
function PreparePickerEntityXml(key, dispval) {
return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
function GetCurrentUserAndInsertIntoUserField() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
this._currentUser = web.get_currentUser();
context.load(this._currentUser);
context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
Function.createDelegate(this, this.onFailure));
function onSuccess(sender, args) {
SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
this._currentUser.get_title());
function onFaiure(sender, args) {
alert(args.get_message() + ' ' + args.get_stackTrace());
ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
</script>
More information:
http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
Best Regards,
Linda Li
Linda Li
TechNet Community Support
Maybe you are looking for
-
I have two issues since upgrading to FF4. The first issue is, when I click on a bookmark it will not automatically open in a new tab. I do have this option checked in my preferences, but it will not work. The second issue is when I search in the Goog
-
Error in Installing Webcenter Sites
Hi ., Iam getting the below error in installing the webcenter sites in Linux,Tomcat server. localhost.log SEVERE: Servlet.service() for servlet cas threw exception java.lang.NullPointerException at com.fatwire.cas.web.NoSuchFlowExecutionExcepti
-
Hi, I'm getting the "DLL Initialization Failed" error message in Windows NT, specifically on the "ddraw.dll" file. I did a google.com search and found the following post: http://forum.java.sun.com/thread.jsp?forum=32&thread=232065 Has anyone had any
-
Hi I have a Macbook Pro, and am trying to install windows XP with bootcamp. when the intallation reaches setting the regional date and time it freezes. I have tried woth a non apple mouse to no avail. I have also got fusion for when windows in runnin
-
Looking for a Third Party document editor
I am running a Palm IIIxe with Palm OS 3.5 on a Vista 32 bit laptop with Palm Desktop 7.2 with HOTSYNCSTETUP patch. I am looking for a document editor that I can use so that I can create text documents and import them into my wordprocessor after syn