SharePoint PnP PowerShell Provision World Clock Web Part on the Modern page

I'm working on providing modern team website sites using PNP Powershell. We try to add the World Clock Web Part on the page, but we do not get the World Time Watch Web Part's internal name to add it to the page. Where do we get the internal name of the World Clock or the entire internal name of the OOTB Web Parts?
Thanks for your help!

Powershell – Problem attaching a string to the end of all file names in Power Shell

I have files look like


I try to add -b String up to the end of all file names, if the rename power shell command is used as follows

D:icons> Dir | Rename-Item -NewName {$ -replace ".","-b."}

to get these


but that does not change anything. Could you please tell me how this can be achieved?

SQL Server 2014 – How do I create a Powershell script job?

I have a powershell script that erases old backups from NAS storage. I already tested it with Windows Powershell and it works, but I could not do the same in SQL Server. I created a cmdExec job and then wrote the following script (script is on the desktop):



".deleteold.ps1 -FolderPath \192.168.x.xBackups -FileAge 2 -ListOnly -LogFile \192.168.x.xBackupslog.log"

However, I am not getting any results because the job will continue to run indefinitely until I finish it.

Powershell – SharePoint Online Add a cross-site search with PnP and XML

I'm trying to set up a cross-site lookup field with XML (which I've been able to do in previous SharePoint On-Premises environments). However, I have some issues with creating a similar configuration in my tenant-based SharePoint Online environment.

My destination configuration contains the following details:

  1. Two (modern) team sites, both at the same site level and both linked to one
    Team (Hub) Site.
  2. SiteA has a list of projects / products.
  3. SiteB has a list of records that contain a search box that needs to point to the project list on SiteA.

For now, I'm just trying to create a site column on SiteB, which is a search box that points to the project list on SiteA. Knowing that this configuration can not be done in the OOB UI, I use PowerShell 5.1 commands and PnP library cmdlets to do this via XML. When I run the following lines, SiteB creates a site column that does not appear to be connected to the project list (SiteA). So when I use them to create a column in a list, there are no values. I also tried to directly create a column in a list (to see if that would work better).

In the following XML file, I specify the GUID of the list on SiteB, which contains the list of projects and the Web Site Web context GUID. I am using NewGuild to generate a new GUID for the new site column.

Some examples of my PS code:

$newguid = (GUID)::NewGuid()

$fieldXML = ''

Add-PnPFieldFromXml -FieldXml $fieldXML

One thing I noticed (and that puzzled me) is that when I use Get-PnPWeb to get the WebID (which I believe), the returned GUID for SiteA and SiteB are exactly the same. I've used separate PowerShell consoles to extract information for the sites separately to make sure the commands run on the right sites. So I'm wondering if I'm using the right GUID in my XML code (for WebId) to point to the web (or site) that contains the project list.

I'll keep trying, but I hope someone has some suggestions or insights about configuring XML for SharePoint Online and successfully setting up cross-site search.

UPDATE on the original question

I have continued to work on this topic. I've worked with two team sites, both of which are mapped to a hub site. But then I decided to work with two different team sites – which are not associated with any hub sites. In this case, the WebIDs (LookupWebIDs) were different. So I reconfigured my XML and used Add-PnPFieldFromXML, which created a new site column (no errors) and checked out the property values ​​for the new column as needed.

$fieldXML = ‘’

Add-PnPFieldFromXML -fieldXML $FieldXML (to create the new Test Column on Site A)

*Check properties*
PS C:> $testCol.LookupList
PS C:> $testCol.LookupWebID


But when I tried to use the new column in a list – the pulldown has no values ​​(should be 3 values) – it still does not seem right to connect to the list on another site.

UPDATE 2 – One possible solution

Finally, using PowerShell / GUID / XML, I was able to get the cross-site function to set the SchemaXML property of a search box in my list (SiteB) to point to a list of values ​​(SiteA). GUIDs for List, WebID, and SourceID were set to cross-site values, and everything worked as expected. However, I first had to create a classic site collection (in my online tenant) so I could then create two team sites using the classic SharePoint Team Site template.

Regardless of what I tried, I could not use the cross-site feature for a Modern Team Site template. For me, it only seems to work in sites created with the Classic template. It is still important to find a solution that enables a multi-site search with the Modern configuration. Therefore, this problem is still unresolved. I just wanted to share what worked – just in case it helps someone else.

Delete over 5000 items SharePoint Online Powershell

I am trying to delete about one million items from a SharePoint Online Library. I think the following code (found on the web) stacks this on <5000 elements, but it still fails with an error:
Error deleting list items! Exception when calling "ExecuteQuery" with "0" arguments: "The attempted operation is not allowed because it exceeds the administrator-enforced list view threshold."

It uses CAML, but I think it will delete one file at a time?
I can not even delete the library! Any ideas why?

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll"
Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll"

#Config Parameters
$SiteURL= "https://mysite/sites/subsite"
$BatchSize = 500

#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred

    #Get the web and List
    Write-host "Total Number of Items Found in the List:"$List.ItemCount

    #Define CAML Query
    $Query = New-Object Microsoft.SharePoint.Client.CamlQuery
    $Query.ViewXml = "$BatchSize"

    Do { 
        #Get items from the list in batches
        $ListItems = $List.GetItems($Query)

        #Exit from Loop if No items found
        If($ListItems.count -eq 0) { Break; }

        Write-host Deleting $($ListItems.count) Items from the List...

        #Loop through each item and delete
        ForEach($Item in $ListItems)

    } While ($True)

    Write-host -f Green "All Items Deleted!"
Catch {
    write-host -f Red "Error Deleting List Items!" $_.Exception.Message

Convert PnP Powershell Online Code into SharePoint 2013

I've written code with PnP PowerShell for SharePoint Online, but now I need to port it to SharePoint 2013. Although I had full control over SharePoint Online, I do not have administrative rights to SharePoint 2013.

The following code simply goes through a site collection and subsites, looking for lists that support a specific content type. Then, the contents of each list are output in a report.

I am confused about the connection to SharePoint on-prem. Online I use:

 Connect-PnPOnline -Url $sourceUrl -CurrentCredentials

For example, in SharePoint 2013, Powershell 5.1 will run. Besides the connection, is there really not much to change? Is there?

 Get-SPOnlineFileDetails -sourceUrl "" -Recurse $true -IncludeFileSize $true | Export-Csv -NoTypeInformation -Path "C:UserswxmuldomDocumentsDataSPOnlineDetails.csv"

    function Get-SPOnlineFileDetails()
            (Parameter(Mandatory=$true,ValueFromPipeline, HelpMessage="SharePoint Online source site URL"))
             Write-Host "###################### Pull Details From SharePoint Online ######################" -ForegroundColor Green
             Write-Host "Provided Source URL :"$sourceUrl -ForegroundColor Green

                     Connect-PnPOnline -Url $sourceUrl -CurrentCredentials
                     $web = Get-PnPWeb

                     PopulateData -web $web -incldeFileSize $IncludeFileSize

                     if($Recurse -eq $false){
                         Get-PnPSubWebs | %{
                          PopulateData -web $_ -incldeFileSize $IncludeFileSize                   
                         Get-PnPSubWebs -Recurse | %{
                          PopulateData -web $_ -incldeFileSize $IncludeFileSize                   
                Write-Host $_.Exception.Message -ForegroundColor Red


    function PopulateData($web, $incldeFileSize){
            Write-Host "Current Site " $web.url -ForegroundColor Cyan 
                      $libs = Get-PnPList -Web $web | Where{($_.BaseType -eq “DocumentLibrary”) }

                      foreach($lib in $libs){
                         $libitems = (Get-PnPListItem -Web $web -List $lib -Fields "FileLeafRef","Name","Title","Author","Modified","Created","KBAbstract","KBContentAuthor","KBCategory","Publish","KBPublishDate").FieldValues

                           foreach($libitem in $libitems)
                                 if($libitem.FSObjType -eq "0"){
                                  $data = @{
                                              "Web Name" = $web.Title

                                              "Library Name" = $lib.Title
                                              "File Name" = $libitem.FileLeafRef
                                              "Abstract" = $libitem.KBAbstractMicrosoft.SharePoint.Client.FieldUserValue
                                                $value = $libitem("KBContentAuthor")
                                                $user = Get-PnPUser -Identity $value.LookupId
                                               "Content Author" = $user.Title
                                               $MMSFieldValueColl = $libitem("KBCategory") 
                                                #Concatenate each term in the value collection
                                                $MMSFieldTerms = ""
                                                Foreach ($MMSFieldValue in $MMSFieldValueColl) {

                                                    if($MMSFieldValue.label -ne $null)
                                                        $MMSFieldTerms+=$MMSFieldValue.label+"; "
                                                Write-Host $MMSFieldTerms

                                             # "Knowledge Area" = $libitem.KBCategory
                                              "Publish" = $libitem.Publish
                                              "Published Date" = $libitem.KBPublishedDate.LookupValue
                                              "File URL" = $libitem.FileRef
                                              "Modified Date" = $libitem.Modified
                                              "Created By" = $libitem.Author.LookupValue
                                              "Created Date" = $libitem.Created
                                              "Modified By" = $libitem.Editor.LookupValue
                                              "File Size (KB)" = $null
                                 if($incldeFileSize -eq $true){
                                        $file = Get-PnPFile -Url $libitem.FileRef
                                        $data("File Size (KB)") = $file.Length / 1KB
                                  New-Object PSObject -Property $data

Powershell – Is there a hidden name that I can check in Windows Explorer folders and files?

I'm writing a script to copy a directory that compares a live directory with a backup directory. When it is run, folders in the backup directory are deleted when it no longer exists in the live directory, and new folders and files in the live directory are copied to the backup directory.
I'm writing scripts with Powershell, but one thing I've noticed is that the Change Date property does not change when a file or "Name" directive is changed just when its contents change.
My question is: Is there a hidden naming convention that essentially means "The name is different, but this is still the same file / folder as before"?

I would simply delete the folder in the backup directory and copy the entire "renamed" updated folder and its contents from the live directory, but if there is something I could use to automatically "" recognize a renamed file through a PSscript "It could shrink the directory down to much runtime.

All answers appreciated!

Powershell – What is a SharePoint Authentication Area (on site)?

The authentication scope is set when you set up an OAuth trust with a service such as Workflow Manager or SharePoint Add-ins.

The realm must be set to an identical value when SharePoint Service applications are published / used. If you need to deploy addins during an upgrade, such as For example, if you have a SharePoint 2013 farm with deployed SharePoint add-ins, you must set the realm to an identical value in the SharePoint 2016 farm that you upgrade to.

Powershell – Displays upcoming workflows for the entire Sharepoint

We have SharePoint 2013 environment, we have a problem with workflow manager services. For this reason, no workflows are started automatically when creating / updating.

Even if I manually start the workflow for an item, it remains not started State.

I'm in touch with Microsoft support and they've suggested updating the Workflow Manager version.

Previously, I wanted to know how many workflows are pending at each site.

Can I see this in any way?

postgresql – Postgres with powershell scripts – where do trigger messages go?

I have a Windows (10 Pro) Powershell script that reads messages from an external server and inserts them into a Postges (10.5) database table.

The table defines an AFTER INSERT trigger that contains some RAISE NOTICE statements for generating simple messages. When I manually insert a single record using pgAdmin, the message RAISE appears on the Messages tab.

Where do the trigger messages go if they are put into the same table from a powershell script?
How can I display the trigger messages in the Powershell console window?