0 votes

I'm in the process of creating a Web interface for requesting IT accounts. Upon submission, I want to run a Powershell script that will create an item in a Sharepoint task list.

by (820 points)
0

Hello,

Sorry for the confusion, but we are not quite sure what exactly you need to achieve. However, the following script from our repository should be helpful: https://www.adaxes.com/script-repository/create-user-folder-in-sharepoint-library-s61.htm. If you still have issues writing the desired script, we recommend you to contact Microsoft support for assistance. Should you have the script working in Windows PowerShell, but struggle to run it in Adaxes, please, post here or send us (support@adaxes.com) the script and describe the desired behavior in all the possible details with live examples.

0

Hello! The script you reference is providing instructions on adding a FOLDER to a Sharepoint library. I'm interested in adding a task item to an existing Sharepoint list. Here's an example of a script that I'm trying to run that fails trying to add a PPSnapin to Sharepoint:

Import-Module Adaxes

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

try
{
    $SPWeb = Get-SPWeb "https://wakecountync.sharepoint.com/sites/AppDevTeam/"
    $List = $SPWeb.Lists["WR"]

    $newItem = $List.items.add()
    $newItem["Task Name"] = "Adaxes - Test"
    $newItem["Assigned To"] = "Sandra Mitchell"
    $newItem["Requesting Dept/Div/Team"] = "IS"
    $newItem["Requested By"] = "Fred Flintstone"
    $newItem.update()

    $SPWeb.Dispose();
}
catch
{

}
0

Hello,

For us to help you with the script, please, specify the following:

  • Did you install the SharePointServer PowerShell module on the computer where Adaxes service runs?
  • Did you try running the script in Windows PowerShell? Does it work fine? If you face any error messages, please, post here or send us (support@adaxes.com) screenshots.
  • What exactly do you mean by fails trying to add a PPSnapin? Do you face any error messages? If you do, please, post here or send us (support@adaxes.com) screenshots.

Any additional details will be much appreciated.

0

Thanks for the reply and my apologies for being rather vague in my request.

  • I have not installed the SharepointServer powershell module. I looked at the link you provided and it appears to deal with administering the Sharepoint environment, not adding items to an existing Sharepoint list
  • My previous attempts at the running the script were done from the Windows Powershell ISE on a test Adaxes server.
  • The error message I get is: Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5. At C:\Users\SMitchell\Documents\WindowsPowerShell\Scripts\AddToSharepointList.ps1:4 char:5
  • Add-PSSnapin Microsoft.SharePoint.PowerShell
  • 
      + CategoryInfo          : InvalidArgument: (Microsoft.SharePoint.PowerShell:String) 
      [Add-PSSnapin], PSArgumentException
      + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapin 
     Command

1 Answer

0 votes
by (250k points)

Hello,

Thank you for the provided details. The error occurs because the Add-PSSnapin cmdlet must be executed on the computer where SharePoint is installed. It will require establishing a remote PowerShell session to the computer as it is done in the script we referenced in our first comment. You can try replacing the part in the script for working with the SharePoint folder with the code for the SharePoint list update.

Related questions

0 votes
1 answer

I would like to add a parameter for country to a custom command. Since the country has to be entered correctly in order for Active Directory to accept it, I would like to ... ? I didn't find it in the documentation and the sample scripts didn't use parameters.

asked Jun 4, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

Occationally Service Desk staff need to clear a DNS record when a desktop has been reimaged but is keeping the same name as loses the ability to manage its original DNS ... running in ADAXES. Can I just install the applet on the ADAXES server using powershell?

asked Jan 17 by stevehalvorson (40 points)
0 votes
1 answer

I had a script that would copy the values from adm-CustomAttributeTextMultiValue1 and save them into extensionAttribute15 as a comma seperated list. The script somehow got deleted and I can't seem to find the tutorial I used to create it before.

asked Jul 1, 2022 by jordan (110 points)
0 votes
0 answers

usually we have to set up users account with access to many share mailbox. However, the time consuption adding those emails one by one it is too much as we needs to sep up many users in one day and that task can take from 10 minutes to an hour.

asked Apr 29, 2021 by Sandovis (20 points)
0 votes
1 answer

With Active Directory Users and Computers, I can add group members by copying a list of usernames and pasting them into the Add Members dialog box. This is very quick and easy. How can I do this with Adaxes? It seems that I can only add one member at a time.

asked Feb 24, 2017 by abarker5 (80 points)
3,063 questions
2,776 answers
7,133 comments
429,243 users