Skip to content

Instantly share code, notes, and snippets.

@jtn-webkoncept
Created January 5, 2021 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtn-webkoncept/5fa2b0f1b8fde93932006491c89352da to your computer and use it in GitHub Desktop.
Save jtn-webkoncept/5fa2b0f1b8fde93932006491c89352da to your computer and use it in GitHub Desktop.
$pluginpath = "forminator/forminator.php"
$cosandsec = "consumer_key=ck_59395753e8b8&consumer_secret=cs_8f7452d67154e10d1b8056"
$FileList = (Get-ChildItem 'C:\Users\Dern\Desktop\PS2020\MainWP\PUT-Pluginupdate\updatelist\updateme.txt').fullname
$c1 = 0
$lineamount =
$m = Get-Content -Path $FileList | Measure-Object -line
@($m).lines
$myOutput = @() # Declare empty array
foreach ($listedid in $FileList) {
$myOutput += foreach ($websiteid in (Get-Content $listedid)) {
$c1++
Write-Host "Processing $websiteid"
Write-Progress -Id 0 -Activity 'Running plugin updates' -Status "Processing $($c1) of $(@($m).lines)" -CurrentOperation $websiteid -PercentComplete (($c1 / @($m).lines) * 100)
try {
$Url = "https://test.dk/wp-json/mainwp/v1/site/site-update-item?site_id=$($websiteid)&type=plugin&slug=$($pluginpath)&$($cosandsec)"
$updateprocess = Invoke-RestMethod -Method 'Put' -Uri $url
$updateprocess.flag
write-host "dette er url $url"
[PSCustomObject]@{
websiteid = $websiteid
Exceptionmessage = $updateProcess.success
StatusdescriptionValue = '200'
Statusdescription = 'SUCCESS'
}
} catch {
# catcherrors
[PSCustomObject]@{
websiteid = $websiteid
Exceptionmessage = $_.Exception.Message
StatusdescriptionValue = $_.Exception.Response.StatusCode.value__
Statusdescription = $_.Exception.Response.StatusDescription
}
}
}
}
$myOutput | Select-Object -Property websiteid,
Exceptionmessage,
Exceptionresponse,
StatusdescriptionValue,
Statusdescription|
Export-Csv -NoTypeInformation -Path C:\Users\Dern\Desktop\PS2020\MainWP\PUT-Pluginupdate\Output\output.csv
# or
$myOutput | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment