Azure
Azure HTTP PowerShell Perform App To Get Knowledge Utilizing Credentials
Overview
This text offers you the essential thought about easy methods to get information from a SharePoint Listing utilizing Azure HTTP PowerShell Perform App with the assistance of userid and password.
Steps
- In case you arrange a brand new Azure Surroundings, then first we have to set up SharePointPnPPowerShellOnline
- Open cloud shell
- Run command “Set up-Module -Identify SharePointPnPPowerShellOnline”
Go to Perform App, if operate is already Obtainable, we are able to use the identical or we are able to create a brand new one. To create a brand new Perform inside Perform App or new Perform App refer right here.
Below this folder Add All PnP PowerShell associated information.
Notice
You possibly can obtain package deal from the beneath URL
You possibly can obtain package deal from the beneath URL
https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline/3.21.2005.2
- utilizing namespace System.Internet
- Import-Module D:homesitewwwrootGetDatamodulesSharePointPnPPowerShellOnlineNewtonsoft.Json.dll’
- Write-Host “Powershell http set off”
- $requestBody = Get-Content material $req -Uncooked | ConvertFrom-Json
- $serviceaccount = $env:Userid
- $serviceaccountpassword = $env:Password
- $listname = “[listname]”
- $siteurl = “https://[tenantname].sharepoint.com/websites/[siteurl]”
- $secpassword = ConvertTo-SecureString -String $serviceaccountpassword -AsPlainText -Power
- $cred = New-Object -TypeName System.Administration.Automation.PSCredential -ArgumentList $serviceaccount, $secpassword
- Join-PnPOnline -Url $siteurl -Credentials $cred
- $net = Get-PnPWeb
- $title = $net.Title
- $listitems = Get-PnPListItem -Listing $listname
- $listArray = New-Object System.Collections.Generic.Listing[System.Object]
- foreach ($merchandise in $listitems)
- {
- $listArray.Add([hashtable]@{
- DisplayTitle=$merchandise[“Title”];
- Id= $merchandise[“ID”]
- }
- )
- }
- $json = $listArray | ConvertTo-Json
- Out-File -Encoding Ascii -FilePath $res -inputObject $json
Notice
Please replace tenantname, siteurl, listname
- Save and attempt to run; it should give error as a result of we didn’t specify Surroundings properties “UserID” & “Password”
- Go to “Platform Options” ==> Configurations
- Click on on + New Utility Setting
- After including each Userid & Password the configuration settings will appear to be beneath, then click on on Save.
- Go to operate and click on on Run
- Copy Perform URL and run in browser, it should return information in JSON format.
Sumamry
Utilizing Azure Perform App we are able to use SharePoint Knowledge to Open supply, any HTML or different system.
Notice
This code will work if multifactor authentication isn’t enabled on specified Userid.
If multifactor authentication is enabled then consult with the subsequent weblog.