Friday, February 19, 2021

Powershell and Uptimerobot

Uptimerobot can be quite tedious when you need to update many monitors at once.
For example say you bought the license for Uptimerobot and now you want to change 50 monitors to check status every 60 seconds instead of the free modes 300 second interval. 

Luckily Uptimerobot have a great API that we can work with powershell against.

getmonitors.ps1 is method to export all monitors to local file. For easier import to another account, or just a small backup just in case. All monitors on account is exported to file note.txt. Using https://api.uptimerobot.com/v2/newMonitor/getMonitors

addmonitors.ps1 is example of how to add new monitor using https://api.uptimerobot.com/v2/newMonitor

editMonitors.ps1  is method for updating all monitors in account to use 60seconds interval.
Using
https://api.uptimerobot.com/v2/editMonitor


Friday, November 27, 2020

Sharepoint 2019 and mysites

 I had some problems with the old familiar "Working on it" for mysites in Sharepoint 2019. It was difficult to find information about this, Im guessing the installation base for world wide on-premise installations is dropping.

Key information when troubleshooting

- On User Profile, attribute "Personal Site Capabilities" is set after user visits mysite for the first time. Default behaviour seems to be setting this to 4. Meaning only storage.
- To reset user mysite, remove the mysite and attributes for mysite and Personal Site Capabilites are automaticly removed from User Profile
- To check ULSViewer for Personal Site Capabilites settings, filter for eventid =  aj1lz
- FeedServiceIdentifier is based on Microfeeds-list on user mysite, without site feature MySiteSocialDeployment no microfeeds is created.
- User Profile Service Application_ActivityFeedJob is running at 10min interval.
- To track mysite creating in ULSViewer, filter on Category = Personal Site Instantation

To solve the problem

After verifying all the user profile service properties and mysite settings I ended up with what might be a bug or might be design. The MySiteSocialDeployment seems to be missing on the default mysite template. So using the solution from Trevors site below i built some scripts for easier deployment in case Microsoft updates onet.xml i future updates.

So basicly first update onet.xml configuration site with ID 10 to include the missing MySiteSocialDeployment-feature
Then deploy the updated file to all members with copyupdatefile.ps1
Finally update sitemaster with newsitemaster.ps1
Remove previously created mysites to trigger mysite-creation with correct features.



References:
Details about PersonalSiteCapabilites
the fix from Trevor
Good details about Fast Site Creating
Another site with same fix
German site using the same fix

Monday, November 02, 2020

Handle multiple versions of powershellPnp with Sharepoint

 This is a nice way to handle accessing different versions of PNPPowershell. 
I use this when switching between onpremise environments of different version and online.

Note that env-variables can't be used until session, like ISE is restarted. Otherwise can variable be accessed immediatly using 
[System.Environment]::GetEnvironmentVariable('SharePointPnPPowerShell2019','machine')

setupEnv.ps1 downloads named modules in $array to $saveFolder. 
Then locates psd1-file and adds this as a enviroment variable with name in arrayobject. 
To use the module access env-variable with $env:name as showed in importModule_Example.ps1


References:
https://www.erwinmcm.com/running-the-various-versions-of-pnp-powershell-side-by-side/



Tuesday, June 02, 2020

Converting csv to excel

Using the useful powershell module importExcel
I could use this to import folder with csv-files to a excelfil for more easy viewing for common users.
Use commented install-module line for first run.




References:
https://github.com/dfinke/ImportExcel

Tuesday, April 21, 2020

Using powershell with UptimeRobots API

I got a chance to test Uptimerobots API with Powershell and I used it with a csv-list of urls with keywords to update my uptimerobot account.
Pretty good stuff where you also can output all your monitors with uptimelogs directly to PowerBI or equivalent.

Code:


To get UptimeRobot status from PowerBI the following queries can be used:

Example 1 - Simple query

let
   body = Text.ToBinary("api_key=#myAPIKey#&format=json&logs=1"),
   Options = [
   Headers=[#"Content-type"="application/x-www-form-urlencoded", #"cache-control"="no-cache"],
   Content=body
   ],
   result = Web.Contents(url, Options)
in
    result


Example 2 - Query using records


let
   content= [
      #"api_key"="#myAPIKey#",
      #"format" = "json",
      #"logs" = "1"
   ],
   query = Text.ToBinary(Uri.BuildQueryString(content)),
   Options = [
   Headers=[
      #"Content-type"="application/x-www-form-urlencoded",
      #"cache-control"="no-cache"],
      Content=query
   ],
   result = Web.Contents(Url, Options)
in
    result
 
Example 3 - Query using json
 
let
   content = "{
  ""api_key"": ""#myAPIKey#"",
  ""format"": ""json"",
      ""logs"": ""1""        
    }",
   query = Text.ToBinary(Uri.BuildQueryString(Json.Document(content))),
   Options = [
   Headers=[
      #"Content-type"="application/x-www-form-urlencoded",
      #"cache-control"="no-cache"],
      Content=query
   ],
   result = Web.Contents(Url, Options)  
in
    result

Tuesday, April 14, 2020

SelfService sitecollections in Sharepoint 2019

With Sharepoint 2019 we now have the ability to allow users to create site collections outside their own mysite themselves. This allows for less administration.
The drawback of this solution is that you can only create managed path sites on primary Alternate Access for webapplication. 
Microsofts documentation leaves some holes in regards to how to activate selfservicing functions with powershell in Sharepoint 2019 so I digged for the related values and found settings below. Most are obvious, one wasn't.


Script below




References:
https://docs.microsoft.com/en-us/sharepoint/sites/configure-self-service-site-creation-in-sharepoint-server-2019

Friday, January 31, 2020

Blobcache issues

I had some weird problem with images in Sharepoint 2013.
Issues were for example
  • Updated images didn't work, old images still showed for clients. 
  • Change imageproperties didn't work either
  • Changing website logo didn't work
BlobCache quickly became as suspect, so we tried to flush the blobcache the proper way with flushBlobCache.ps1 but the folders in the blobcache-directory didn't get recreated.
Expected behaviour is when flushblob has run on farm, the folder under siteID in blob-directory will get a new created date and new name.
For me, they just left the old folder without change on certain farm-members.

After searching for a official solution I landed on my own fix which was as follows
  1. Redirect trafik from webfrontend or do this during servicewindow
  2. Update url and run setBlobDisabled.ps1 (or disable blob manually in web.config)
  3. This will cause a reset to Application Pool and blobfolder will stop updating change.bin file in blob temp-directory
  4. Rename or delete folder with SiteID, for example E:\Blob\14\354006434 to 354006434_old
  5.  Update url and run setBlobEnabled.ps1
  6. Problem solved.


 

Powershell and Uptimerobot

Uptimerobot can be quite tedious when you need to update many monitors at once. For example say you bought the license for Uptimerobot and n...