Skip to content

Instantly share code, notes, and snippets.

Anatoly Mironov mirontoli

Block or report user

Report or block mirontoli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View get-secret.js
try {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/sites/DailyWork/_api/web/Lists/GetByTitle('Secrets')/Items", true);
xhr.setRequestHeader("Accept","application/json;odata=nometadata");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var content = xhr.responseText;
var time = new Date().getTime();
var url = _spPageContextInfo.webServerRelativeUrl
View try-aad-250-limit.ps1
# This script will try to create 251 groups
# The last one should fail
# configuration:
# 1. create an account nonadmin@takana16.onmicrosoft.com
# 2. go to https://developer.microsoft.com/en-us/graph/graph-explorer, make a call and grab the access token
$token = "eyJ0eXAiOiJKV1QiLCJub25jZSI6Iko1WXU2MWRtR3FsR0JaaVJ0YTJsM0duUFdBLW5FY19yWk90aFNFNlg3MUEiLCJhbGciOiJSUzI1NiIsIng1dCI6ImFQY3R3X29kdlJPb0VOZzNWb09sSWgydGlFcyIsImtpZCI6ImFQY3R3X29kdlJPb0VOZzNWb09sSWgydGlFcyJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8wMzRmOGFhOC01NTBiLTRjZmEtODZhNi03NWFkNTdmMTNkNDkvIiwiaWF0IjoxNTcxOTk3NzQ5LCJuYmYiOjE1NzE5OTc3NDksImV4cCI6MTU3MjAwMTY0OSwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFTUUEyLzhOQUFBQWFmNDJjVjFMTUdZRzlmMFh4TDNCK0pLbTdrR2NNQ3FLcHI3TUtFVlNwdUU9IiwiYW1yIjpbInB3ZCJdLCJhcHBfZGlzcGxheW5hbWUiOiJHcmFwaCBleHBsb3JlciIsImFwcGlkIjoiZGU4YmM4YjUtZDlmOS00OGIxLWE4YWQtYjc0OGRhNzI1MDY0IiwiYXBwaWRhY3IiOiIwIiwiZmFtaWx5X25hbWUiOiJNaXJvbm92IiwiZ2l2ZW5fbmFtZSI6IkFuYXRvbHkiLCJpcGFkZH
View col-form-boolean-circle.json
{
"elmType": "div",
"style": {
"padding": "0 4px",
"font-size": "2em",
"text-align": "center"
},
"children": [
{
"elmType": "span",
View get-totals-from-listview.ps1
#This script gets the totals from a list view
Connect-PnPOnline https://siteurl
$context = Get-PnPContext
$list = $context.Web.Lists.GetByTitle("mylist")
$view =$list.Views.GetByTitle("MyViewWithTotals")
$context.Load($view)
$context.ExecuteQuery()
# we only need one item, not more
$viewxml = $view.ListViewXml -replace '<RowLimit Paged="TRUE">\d*</RowLimit>','<RowLimit>1</RowLimit>'
$result = $list.RenderListData($viewxml)
View update-site-locale-pnp.ps1
Connect-PnPOnline https://takana16.sharepoint.com/sites/001
$web = Get-PnPWeb
$ctx = Get-PnPContext
$ctx.Load($web.RegionalSettings)
$ctx.ExecuteQuery()
$tz = $web.RegionalSettings.TimeZones.GetById(4) # Stockholm, UTC+1
$web.RegionalSettings.Timezone = $tz
$web.RegionalSettings.LocaleId = 1053 # Swedish
$web.RegionalSettings.FirstDayOfWeek = 1 # Monday
$web.RegionalSettings.Time24 = $true
View pnp.ps1
# Install
Install-Module SharePointPnPPowerShellOnline -Scope CurrentUser
# check version
Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
# Update
Update-Module SharePointPnPPowerShell*
# connect with mfa
Connect-PnPOnline -Url https://takana15.sharepoint.com/sites/tolle016 -SPOManagementShell -ClearTokenCache
# get template; you need to extract it, it is just a zip file
Get-PnPProvisioningTemplate -out template.pnp
View group-crud.md
POST https://graph.microsoft.com/v1.0/groups/
{
  "description": "tolle035",
  "displayName": "tolle035",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": true,
  "mailNickname": "tolle035",
View asp.net-core-react_azure-pipelines.yml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
View spo.ps1
#Connect Disconnect
#https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps
$adminUPN="admin@takana15.onmicrosoft.com";
$orgName="takana15";
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password.";
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential;
#oneliner:
Connect-SPOService -Url https://takana15-admin.sharepoint.com -Credential (Get-Credential -UserName spadmin@takana15.onmicrosoft.com -Message "psw")
Disconnect-SPOService
View disable-group-creation.ps1
#https://docs.microsoft.com/sv-se/office365/admin/create-groups/manage-creation-of-groups?view=o365-worldwide
Connect-AzureAD
$newSetting = Get-AzureADDirectorySetting | ? { $_.DisplayName -eq "Group.Unified" }
$settingsObjectID = $newSetting.id
$settingsCopy = Get-AzureADDirectorySetting -Id $settingsObjectID
$settingsCopy["EnableGroupCreation"] = $false
$creatorsGroup = Get-AzureADGroup -SearchString "Creators"
$settingsCopy["GroupCreationAllowedGroupId"] = $creatorsGroup.ObjectId
Set-AzureADDirectorySetting -Id $settingsObjectID -DirectorySetting $settingsCopy
You can’t perform that action at this time.