SharePoint Module for managing lists, items and files

The module is a massive work comprising over 3000 lines of code and 50 SharePoint Online cmdlets for managing: lists list columns list items files content type taxonomy

SPOMod.rar
 
 
 
 
 
4.9 Star
(37)
13,678 times
Add to favorites
Office 365
3/23/2020
E-mail Twitter del.icio.us Digg Facebook
  • Files missing?
    2 Posts | Last post December 12, 2019
    • Hi Arleta,
      
      I could not find SPOModCurrent.psm1 and SharepointModuleForListItemsFiles.psm1 in below instrcutions. I installed SDK but, without these files I could not move ahead. Please assist me.
      
      b) Open SPOModCURRENT.psm1 in NotePad or Powershell ISE.
      
      Import-Module c:\thePathWhereYouDownloadedIt\SharePointModuleForListsItemsFiles.psm1
    • Hi Anand91,
      
      I corrected the instructions. Thanks for pointing it out!
  • Cannot authenticate
    2 Posts | Last post December 12, 2019
    • No matter what I try, it tells me that my credentials are wrong.
      
      We use MFA and there is no way around it. ISO 27001 policy. :(
      
      AppPasswords don't seem to work either. I am at a loss. Any ideas?
    • Unfortunately, the module doesn't handle MFA. 
      
      Please have a look at PnP cmdlets. 
  • Get-SPOListItems - datetime
    2 Posts | Last post November 17, 2019
    • Hi Arleta,
      I have list with a Date & Time column. When I run Get-SPOListItems to pull the data, the time is one hour offset i.e. on List viewed via browser it has 23/09/2019 09:00:00 , however Get-SPOListItems shows 23/09/2019 08:00:00
      
      The computer I am running the Powershell has correct date/time.
      
      Is this a problem from the SharePoint backend ? Any help would be much appreciated, thank you.
      
    • What are the user and the site timezone settings?
  • Version History Changed By User
    2 Posts | Last post November 17, 2019
    • HI Arleta,
      thank you so much for these utilites you've really helped lighten the load we have for a client who's CEO's computer decided to randomly upload old content into a site and rollback lots of files. 
      Is there a way when using Get-SPOListItemVersions that we can see WHICH user changed a file? When I run an example command such as this, 
      
      Get-SPOListItemVersions -ListTitle 'documents' -ItemID 77217 | ft -AutoSize
      
      all I see are 'Microsoft.SharePoint.Client.User' listed under the Created By field. Am i missing something, or do I need to pass this object into something else to get the user name? 
      
      Also are there any utilites/methods you've made or know of, that can roll back a file to a previous version? We can do it manually on the site but that'll be a long slow process.
      
      Many thanks once again,
      Richard.
    • Hi Richard,
      In order to "decipher" the user you need to load the user object. Currently the module doesn't do that. You can add this functionality yourself. Just have in mind that it will slow down the execution a little.
      Open the .psm1 file and try to update the loop below.
      
        foreach($vers in $file.Versions)
        {
          
          	$user = $vers.CreatedBy 
      	$ctx.Load($user)
          	$ctx.ExecuteQuery()		
          	Write-Output $vers
      	Write-output $user	
        }
  • Thanks!
    2 Posts | Last post February 22, 2019
  • adding values to a list choice column
    2 Posts | Last post January 19, 2019
    • Is it possible to get a Set-SPOListChoiceColumn function? (currently there's only New-SPOListChoiceColumn) 
      
      We have a multiple choice column which is populated with AD group names. We want to run a scheduled PS script that adds/removes groups to the multiple choice column so that the values to select are always up to date.
      
      Thanks
    • Thank you for the suggestion, Mr Arran. 
      I will see what can be done.
  • Get-SPOListItems Ueage for lists with > 5000 items FIX
    4 Posts | Last post January 19, 2019
    • The original premise of this usage was incorrect.
      ORIGINAL: Read all records from (1 to X) Where X is the total number of records in the list
      This only does not take into account deleted records.  You could have 1 record but the ID=25643.
      CORRECTED:  Read all records from (1 to X) Where X is the ID OF THE LAST RECORD CREATED in the list
      
      Where can I send the corrected code.
    • Hi Chris,
      Thank you for all your feedback. 
      
      Please post it here in the comments. Unfortunately there is no collaboration possibility on Technet Gallery.
    • Hey Chris, can you please share your fixed code. I'm attempting to fix myself but am a little stuck.
      
      Thanks,
      Nathan
    • Hi,
      
      In order to collaborate better, I posted SPOMod also on GitHub. Have a look at https://github.com/PowershellScripts/SPOMod and don't hesitate to add your comments, issues and fixes. 
  • Cannot connect
    1 Posts | Last post November 07, 2018
    • Hi Arleta - I am getting the following error when I ran Connect-SPOCSOM and provide the Cred and URL. Please advise what I might be doing wrong? Thanks!
      
      New-Object : Exception calling ".ctor" with "2" argument(s): "The 'username' argument cannot be null.
      Parameter name: username"
      At C:\temp\SPOMod\SPOMod\SPOModCURRENT20170918.psm1:3710 char:22
      + ... edentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCr ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
          + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
      
      Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
      At C:\temp\SPOMod\SPOMod\SPOModCURRENT20170918.psm1:3711 char:3
      +   $ctx.ExecuteQuery()
      +   ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : WebException
  • Updated Connection Options
    3 Posts | Last post March 13, 2018
    • Just a suggestion to those out there that do not like to enter passwords into PowerShell. I have been using the CredentialManager module that allows you to use a Windows Stored Credential.
      As such I wanted to be able to pass a credential rather than a username/password so I updated the connection Function to support both Credential and Username, this was applied to Get-SPOWeb using the same concept:
      
      Function Connect-SPOCSOM {
      	<#
      		.link
      		http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx
      	#>
      	[CmdletBinding(DefaultParameterSetName="Credential")]
      	param (
      		[Parameter(Mandatory = $True, Position=1, ParameterSetName = "Credential")]
      		$Credential,
      		[Parameter(Mandatory = $True, Position=1, ParameterSetName = "Username")]
      		[string]$Username,
      		[Parameter(Mandatory = $True, Position=2)]
      		[string]$Url
      	)
      
      	Switch ($PSCmdlet.ParameterSetName) {
      		"Credential" {
      			$Username = $Credential.Username
      			$Password = $Credential.Password	
      		}
      		"Username" {
      			$password = Read-Host "Password" -AsSecureString
      		}
      	}
      
      	$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
      	$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
      	$ctx.ExecuteQuery()
      	$global:ctx = $ctx
      }
      
      
    • Thanks R.Variable!
    • How to Connect SPOCSOM automatically? @R.Variable Thank you for your "solution", can you please explain how to use it? i try to get it since yesterday... no luck! Thanks! 
  • Connect-SPOCSOM - unauthorized
    8 Posts | Last post February 28, 2018
    • Hi Arleta
      
      I'm seeing the following error:
      
      Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (401) Unauthorized."
      At C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\SPOModCURRENT20170918.psm1:3711 char:3
      +   $ctx.ExecuteQuery()
      +   ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : WebException
      
      I can't seem to find the error. User is global admin, but have also tried with a few other users, but same error everytime. 
      
      I use the following:
      
      $url="https://mytenant.sharepoint.com/sites/mysite"
      Connect-SPOCSOM -Url $url -Username "martinrask@mytenant.onmicrosoft.com"
      
      Enter password and error occurs.
      
      Any ideas as to the problem?
      
    • Hi Martin,
      
      Do you replace mytenant with the correct value? E.g. 
      https://contoso.sharepoint.com/sites/Recruitment ?
      
      Can you login to the website you enter using a browser and the same credentials?
      
      Are you using two-factor authentication?
      
      What is the exact error message?
    • Hi Arleta
      
      I use the correct url yes.. and I used the script last in December where it worked.
      
      I can login to the website using a browser and the creds I use in the script. 
      I am not using two-factor authentication.
      
      The exact error is:
      
      when I run:
      
      Connect-SPOCSOM -Credential $creds -Url "https://********group.sharepoint.com/sites/**********logistics"
      
      Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (401) Unauthorized."
      At C:\Users\mrt\Desktop\desktop\UserPhoto for O365\SPOMod\SPOModCURRENT20170918.psm1:3711 char:3
      +   $ctx.ExecuteQuery()
      +   ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : WebException
    • I also tried using -username and entering password manually.. That gave the same error.
      
      If I use :
      
      connect-spocsom
      then enter url when it asks
      then enter $creds when it asks for credentials
      
      I get this error:
      
      New-Object : Exception calling ".ctor" with "2" argument(s): "The 'username' argument cannot be null.
      Parameter name: username"
      At C:\Users\mrt\Desktop\desktop\UserPhoto for O365\SPOMod\SPOModCURRENT20170918.psm1:3710 char:22
      + ... edentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCr ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
          + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
       
      Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (401) Unauthorized."
      At C:\Users\mrt\Desktop\desktop\UserPhoto for O365\SPOMod\SPOModCURRENT20170918.psm1:3711 char:3
      +   $ctx.ExecuteQuery()
      +   ~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : WebException
      
      
      That's with the url NOT in ""
    • this is the output of $ctx
      
      PS C:\Users\mrt> $ctx
      
      
      Web                          : Microsoft.SharePoint.Client.Web
      Site                         : Microsoft.SharePoint.Client.Site
      FormDigestHandlingEnabled    : True
      ServerVersion                : 
      Url                          : https://******group.sharepoint.com/sites/******logistics
      ApplicationName              : .NET Library
      ClientTag                    : 
      ValidateOnClient             : True
      AuthenticationMode           : Default
      FormsAuthenticationLoginInfo : 
      Credentials                  : Microsoft.SharePoint.Client.SharePointOnlineCredentials
      WebRequestExecutorFactory    : Microsoft.SharePoint.Client.DefaultWebRequestExecutorFactory
      PendingRequest               : Microsoft.SharePoint.Client.ClientRequest
      HasPendingRequest            : True
      Tag                          : 
      RequestTimeout               : 180000
      StaticObjects                : {[Microsoft$SharePoint$SPContext$Current, Microsoft.SharePoint.Client.RequestContext]}
      ServerSchemaVersion          : 
      ServerLibraryVersion         : 
      RequestSchemaVersion         : 15.0.0.0
      TraceCorrelationId           : 
      
      
      and output of $ctx.credentials
      
      
      
      PS C:\Users\mrt> $ctx.Credentials
      
      UserName                                     
      --------                                     
      ********scripter@**********group.onmicrosoft.com
      
      
      User is member of correct groups etc. and as stated earlier the script with this user did work in December.. which is what's quite strange.
      
      I tried with the script user.. My own SP user and my global admin user.
      
      I made sure to be logged on to the site with the user I ran the script with.
      
    • Can you login using Connect-SPOService and $creds?
      
      I just tested and Connect-SPOCSOM -Credential $creds -Url "https://tenant.sharepoint.com/sites/mine"  works ok for me. I also did not make any changes in the module since October.
      
      It's a wild guess, but could it be a character in your password?
    • Hi Arleta
      
      I can connect with : Get-SPOTenant
      
      Using get-sposervice fails with:
      
      Connect-SPOService : Cannot contact web site 'https://zzzzzzzzz.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response 
      headers are 'X-SharePointHealthScore=1, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically., 
      SPRequestDuration=20, SPIisLatency=1, MicrosoftSharePointTeamServices=16.0.0.7414, X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=0, Content-Type=text/plain; charset=utf-8, 
      Date=Wed, 28 Feb 2018 09:20:32 GMT, P3P=CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'.
      At line:1 char:1
      + Connect-SPOService -Credential $creds -Url "https://zzzzzzzzz.shar ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Connect-SPOService], NotSupportedException
          + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
      
      
    • Hi Arleta
      
      I think I found the problem. At least I've been able to connect.
      
      I did the following:
      
      Connect-SPOService -Url "https://TENANTID-admin.sharepoint.com"
      $TenantSettings = Get-SPOTenant
      $TenantSettings.LegacyAuthProtocolsEnabled
      Set-SPOTenant -LegacyAuthProtocolsEnabled $True
      
      based on this site: 
      
      https://blog.areflyen.no/2017/06/18/problem-with-connecting-to-sharepoint-online-in-office-365-with-powershell-sharepoint-designer-and-other-3-party-tools/
      
      Perhaps it would be possible to adapt the spomod to handle modern creds?
      
1 - 10 of 46 Items