I would like to move a ps script to Azure to run as a runbook. It basically checks all new SharePoint sites and checks if they meet certain criteria, like enables version control if not set.
The script works like:
$sitesdonelist = "c:\log.txt"
$sitesdone = get-content -Path $sitesdonelist
foreach($sitecoll in $sitecollections) {
$currentsite = $sitecoll.Url
if ($sitesdone -inotcontains $currentsite) {
checksite
add-content -Path $sitesdonelist -Value $sitecoll.Url
}
}
I would like this code to work on Azure and part of this is to move the sites done list to an Azure file share and append the processed sites to it. So far I see two options and none of them seem right:
- Download the file to
$env:TEMP
, append and upload on finish: I will miss all sites done if something fails halfway - Download the file to
$env:TEMP
, append and upload after every site: would make the process slow and cause lot of unnecessary data load
Is there a better option? Can I write directly to a file on Azure file share from an Azure PowerShell runbook?