Skip to content

Instantly share code, notes, and snippets.

View dev-kperera's full-sized avatar
🤵‍♂️
On Code

Kushan Perera dev-kperera

🤵‍♂️
On Code
View GitHub Profile
@dev-kperera
dev-kperera / change-biography.yaml
Created May 12, 2024 22:25
Build your own copilot with Microsoft Copilot studio
TODO
@dev-kperera
dev-kperera / Arduino-Temp-Sensor.cpp
Last active March 23, 2024 15:39
Using a Temperature Sensor to Control the Speed of a Motor Using Arduino
float temp;
int tempPin = A1; //arduino pin used for temperature sensor. CHANGE THIS BASED ON YOUR CONFIGURATION
int tempMin = 70;
int tempMax = 75;
int motor = 2; // the pin where motor is connected. CHANGE THIS BASED ON YOUR CONFIGURATION
int motorSpeed = 0;
void setup() {
pinMode(motor, OUTPUT);
pinMode(tempPin, INPUT);
@dev-kperera
dev-kperera / AzureAD - Invite guest users.ps1
Last active February 20, 2020 18:27
CSV headers: InvitedUserEmailAddress, DispName, RedirectURL
# connect
$cred = Get-Credential
Connect-AzureAD -Credential $cred
# setting variables
$invitations = import-csv ..\invitations.csv
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "Hey there! Check this out. I created an invitation through PowerShell"
# loop
$cred = Get-Credential
Connect-AzureAD -Credential $cred
$invitations = import-csv C:\data\invitations.csv
$messageInfo = New-Object Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo
$messageInfo.customizedMessageBody = "Hey there! Check this out. I created an invitation through PowerShell"
foreach ($email in $invitations) {New-AzureADMSInvitation -InvitedUserEmailAddress $email.InvitedUserEmailAddress -InvitedUserDisplayName $email.Name -InviteRedirectUrl https://wingtiptoysonline-dev-ed.my.salesforce.com -InvitedUserMessageInfo $messageInfo -SendInvitationMessage $true}
@dev-kperera
dev-kperera / SharePoint Online - Bulk add items to list.ps1
Created December 19, 2019 19:58
Using SharePointPnP.PowerShell modules.
# variables
$siteURL = "https://org.sharepoint.com/sites/siteName"
$sharePointAdminUser = 'admin@org.onmicrosoft.com'
$cred = Get-Credential -UserName $sharePointAdminUser -Message 'Connect with a user with global level permissions'
# connect
Connect-PnPOnline -Url $siteURL -Credentials $cred
# Import values from CSV
$path = ".\source.csv"
@dev-kperera
dev-kperera / React - Set State with Spread Operator.ts
Last active December 19, 2019 20:00
React setState with spread operator when you need to change values of state object item. Motivation: https://stackoverflow.com/questions/43638938/updating-an-object-with-setstate-in-react
this.setState(prevState => ({
OBJECT_NAME: {
...prevState.OBJECT_NAME,
OBJECT_KEY : NEW_VALUE
}}));
@dev-kperera
dev-kperera / ShareGate - Script to migrate OneDrive with ShareGate libraries.ps1
Last active December 19, 2019 20:00
Eventhough we could migrate OneDrive content with PowerShell. I'm giving a try to migrate content with ShareGate PowerShell addins.
# tenants
$tenantOne = connect-site -Url https://tenantOne-admin.sharepoint.com -Browser
$tenantTwo = connect-site -Url https://tenantTwo-admin.sharepoint.com -Browser
# List of unique user names of users need to migrate
$csvFile = "C:\OneDriveMirationUserEmailList.csv"
$table = Import-Csv $csvFile -Delimiter ";"
# ShareGate incrementatl copy config. This will be only usable if you are copying incrementally
$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate
@dev-kperera
dev-kperera / OneDrive personal site provisioning.ps1
Created April 26, 2019 18:10
Script to provision OneDrive personal sites using ShareGate PowerShell libraries. More information: https://support-desktop.sharegate.com/hc/en-us/articles/115000641328-Get-OneDrive-URL
# Connect to Office 365
$tenant = connect-site -Url https://tenant-admin.sharepoint.com -Browser
# Get list of emails
$eMailCSV = "C:\emailList.csv"
$table = Import-Csv $eMailCSV -Delimiter ";"
# Iterate through emails and provision OneDrive sites
foreach ($row in $table) {
Get-OneDriveUrl -Tenant $tenantMoravia -Email $row.email -ProvisionIfRequired
@dev-kperera
dev-kperera / ConnectSharePointOnline.ps1
Created April 2, 2019 18:13
SharePoint site owners have new options for applying custom styles and colors to sites that make it easier to define and manage themes across site collections
# Commands to connect SharePoint Online
$adminUPN="kushan@contoso.onmicrosoft.com"
$orgName= Read-Host -Prompt 'Name of your Office 365 organization, example: contoso'
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
# Verify SharePont Online Management Shell
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
@dev-kperera
dev-kperera / settings.json
Created September 30, 2018 12:25
Visual Studio (VS) Code My Favorite Settings
{
"git.ignoreMissingGitWarning": true,
"window.zoomLevel": 0.5,
"breadcrumbs.enabled": true,
"editor.wordWrap": "on",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.quickSuggestions": {
"other": true,