Skip to content

Instantly share code, notes, and snippets.

@garrytrinder
Last active December 15, 2018 17:55
Show Gist options
  • Save garrytrinder/8e54b596f33d312a4502a32a11a55463 to your computer and use it in GitHub Desktop.
Save garrytrinder/8e54b596f33d312a4502a32a11a55463 to your computer and use it in GitHub Desktop.
Example of a very basic Azure Automation Runbook that outputs a JSON object
Param(
[Parameter(Mandatory=$true)]
[string]$SiteUrl
)
# ensure that any error stops the job
$ErrorActionPreference = "Stop"
# create connection to SharePoint site
Connect-PnPOnline -Url $SiteUrl -Credentials (Get-AutomationPSCredential -Name "Lundhill")
# get web
$web = Get-PnPWeb
# output json
Write-Output @{WebTitle=$web.Title} | ConvertTo-Json
# clean up SharePoint connection
Disconnect-PnPOnline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment