Simple question: Using a Flow condition, how do you check the value of a SharePoint Yes No field?
My first attempt was to set a variable equal to the SharePoint list value, then check the condition like this:
And, for good reason, this did not work.
My next attempt was to try replacing the condition value with true or false.
And, again, this did not work!
Sooo, what if I convert the true or false to a string?
It worked!
How do you set or update a SharePoint Yes No field using a Flow variable?
Create a string variable, then set the value to true or false.
SharePoint display values:
Yes = true
No = false
Tag Archives: sharepoint
Get Files From a SharePoint Folder Using PowerShell PNP
How do you get all the files from a folder in SharePoint using PowerShell PNP?
$devConn = Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/siteA/siteB" -Credentials -Credentials (Get-Credential) -ReturnConnection
$folderName = "/Shared Documents/myfolder/anotherfolder"
$folderItems = Get-PnPFolderItem -FolderSiteRelativeUrl $folderName -Connection $devConn
foreach($item in $folderItems)
{
Write-Host $item.Name
}
Write-Host "done"
Depending on your needs, you could also use a search query with a path filter to get the files.
Example of using the Get-PnPListItem cmdlet with the FolderServerRelativeUrl parameter.
$devConn = Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/siteA/siteB" -Credentials -Credentials (Get-Credential) -ReturnConnection
$folderName = "/sites/spdev2/bw2/Shared Documents/myfolder/anotherfolder"
$folderItems = Get-PnPListItem -List "Shared Documents" -FolderServerRelativeUrl $folderName -Connection $devConn
foreach($item in $folderItems)
{
Write-Host $item
}
Flow Trigger On SharePoint Item Version
How do you run a Flow on a specific version SharePoint item version?
Create a Flow, then navigate into the Settings of the first step. Scroll down to Trigger Conditions and enter the following:
@equals(float(triggerBody()?['{VersionNumber}']),1.0)

Save the Flow and run a test.
The Flow should only process items / documents where the version is equal to 1.0.
PowerAutomate SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl
{
"inputs": {
"variables": [
{
"name": "varURI-String",
"type": "string",
"value": "/_api/web/GetFolderByServerRelativeUrl('@{triggerBody()?['FolderPath']}')/ListItemAllFields/breakroleinheritance(copyRoleAssignments=false, clearSubscopes=true)"
}
]
}
}
Using a Power Automate Flow to break inheritance on a folder and this error was being returned. The issue turned out to be the path I was trying to use for the folder.
This did not work: LibraryName/Folder
This DID work: /sites/ParentSite/SubSite/LibraryName/Folder’

Copy Files From Azure File Storage to SharePoint
As of today, there is not a Logic App trigger for Azure File Storage, so I went with a schedule-based approach. Yes, this example leaves out a lot of fine-tuning, but it will get you headed in the right direction.
Create a blank Logic app
Trigger: Schedule
Action: Azure File Storage – List files
Action: SharePoint – Create file
After you add the SharePoint action, the Logic App should automatically add a For Each action and place the SharePoint Create File action inside of it.



In the last screenshot, I tested the Logic App by uploading a couple of documents in Azure Storage Explorer, then I manually ran the Logic App (click the Run button).
Again, this is a simple example. The example does not account for processing the same files over and over…
SharePoint Search Query Tool Login
If you have ever worked with SharePoint search you likely already know about the SharePoint Search Query Tool. If you are new to SharePoint and need a little insight into the SharePoint search experience this tool is a lifesaver!
SharePoint Query Tool GitHub: https://github.com/pnp/PnP-Tools/
In future posts, I will outline how to form queries and use the tool but for now, I want to simply connect to my SharePoint Online site.

Enter the URL for your SharePoint site, select the Authentication options shown above, then click Sign-In. If a web login form appears be sure to complete it. If your normal Windows login doesn’t work, try using your work email address and password, and if that doesn’t work try your work email address and App Password.
App Passwords are created and managed at this URL: https://account.activedirectory.windowsazure.com/AppPasswords.aspx
Flow Power Automate and SharePoint Required Fields
On the surface, this request sounded super simple and straightforward. “we need to copy files from a SharePoint library to Blob storage.” Simple enough? Well, yes, but the SharePoint library has a couple of required fields and a Flow is triggered by an action.
Consider what I’m outlining below to be version ONE of the process. In the near future, I will update this post with a slightly more resilient solution.
My SharePoint library has a required field titled DesinationFolder

Context of what I’m doing in the Flow:
Trigger: When files is created in a folder
When a file is added to a library the flow is triggered
Get file metadata
File Identifier: Use File identifier from the step above
Get file properties
Id: Use the ItemId from the previous step
Initialize variable
Name: vCheckedOut
Type: Boolean
Value: Checked out (field from Get properties)
Initialize variable
Name: vFolderPath
Type: String
Value:
Condition
vCheckedOut is equal to true
Yes:
Do until
vCheckout is equal to False
GetFileProperties
Set variable
Name: vCheckedOut
Value: Checked out (value from the Get file properties above)
No:
Set variable
Name: vFolderPath
Value: FolderPath (SharePoint field)
Compose
/blobfolder/vFolderPath (variable)
Create blob
Get-PnPSearchCrawlLog Filter to a List or Library
Using the Get-PnpSearchCrawlLog cmdlet wanted to filter the returned result set to a specific list. Before you begin, you’ll want to make sure you have access to the Crawl Log: https://yourSite-admin.sharepoint.com/_layouts/15/searchadmin/crawllogreadpermission.aspx
Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/food" -Credentials (Get-Credential)
$logs = Get-PnPSearchCrawlLog -filter "https://sharepointed.sharepoint.com/sites/food/Lists/tacos/"
foreach($l in $logs)
{
Write-Host " "
Write-Host $l.Url
Write-Host $l.ItemId
Write-Host $l.LogLevel
Write-Host $l.CrawlTime
}
This will filter the returned results to a specific list. Note: when using Connect-PnPOnline I use my email address and App Password. App Password can be created/found here: https://account.activedirectory.windowsazure.com/AppPasswords.aspx
Get-PnPSearchCrawlLog details: https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnpsearchcrawllog?view=sharepoint-ps
System.MissingMethodException: Method not found Connect-PnPOnline
Using Visual Studio Code and SharePoint PNP I was trying to make some updates to a list but I wasn’t able to connect to a site.
Connect-PnPOnline -Url "https://taco.sharepoint.com/" -Credentials $creds
Error I was receiving:
System.MissingMethodException: Method not found: ‘System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)’.
at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
I tried uninstalling VScode, removed all traces of SharePoint from my laptop, and cleared the GAC. Nothing worked.
Here is what did work:
In VScode:
- Open the Command Palette on Windows or Linux with Ctrl+Shift+P. On macOS, use Cmd+Shift+P.
- Search for Session.
- Click on PowerShell: Show Session Menu.
- Choose one of the ___ (x86) options
Not sure how, but I was using an x64 session and SharePoint PNP clearly didn’t like that.
Edit: Updated VScode to the latest version and it managed to reset my session settings. When this happened, it caused my CSOM scripts to report a The remote server returned an error: (400) Bad Request error. The fix above will resolve the error.
Connect to SharePoint Online Using PowerShell
Update and a much better way to approach this:
Use a SharePoint App Only Client Id and Secret to access the site, list, or library.
Microsoft documentation:
https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
You can create an app principle that is limited to a single site, list, library, or a combination of them:
https://piyushksingh.com/2018/12/26/register-app-in-sharepoint/
$sampleConnect = Connect-PnPOnline -Url "https://YOURsite.sharepoint.com/sites/parent/child" -AppId "12345-94c3-4149-bda5-abcedffadsf" -AppSecret "643r4er5sfdadsfadsfdsf=" -ReturnConnection
Write-Host $sampleConnect.Url
Assumptions:
1) You have created a token in your o365 site
1.1) https://portal.office.com/account/
1.2) On the left site of the page click Security & privacy, then click Create and manage app passwords
1.3) In the app password page click the create button and give it a name.
1.4) Save the password to a secure location.
1.5) There is a better way of doing this that I will cover in a future post.
2) You have downloaded to CSOM DLL(s) from Nuget
Clear-Host
$userName = "me@sharepointed.com"
$pw = "abc123taco" # I"M USING AN APP PASSWORD
$siteCollectionUrl = "https://sharepointed.sharepoint.com/sites/taco"
#Secure the password
$securePassword = ConvertTo-SecureString $pw -AsPlainText -Force
Add-Type -Path "C:\Code\DLL\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Code\DLL\Microsoft.SharePoint.Client.Runtime.dll"
#Create Context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteCollectionUrl)
#Authorise
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $securePassword)
$web = $ctx.Web
$properties = $web.AllProperties
$ctx.Load($web)
$ctx.Load($properties)
$ctx.ExecuteQuery()
Write-Host " Site Collectione URL: $($web.Url)"
Write-Host "Properties are "
foreach ($prop in $properties) {
$prop.FieldValues
}