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 (870 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 (289k 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

Using the powershell module, I know how to create a scheduled task, and also how to bind to a scheduled task that is already known. I also have used code to try creating ... same time as another. These are all one-time tasks and will be removed once executed.

asked Jan 19 by aweight (60 points)
0 votes
1 answer

Hi, In the SDK I find information on how to use Powershell to read and create scripts in custom commands and business rules, but I can not find the same for ... information like the embedded scripts for the report and custom columns? -- Morten A. Steien

asked Jul 27, 2023 by Morten A. Steien (300 points)
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

In a business rule, I'd like to pass Adaxes variables into a powershell script that I'll run. For example, pass %username% into the script so it can be used inside the script.

asked Sep 5 by P-Sysadmin (20 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, 2023 by stevehalvorson (110 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users