Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian T. Jackett BrianTJackett

View GitHub Profile
@BrianTJackett
BrianTJackett / PS-WinGet_Apps_To_Install.ps1
Last active Sep 19, 2020
Script for re-installing applications via winget to new machine
View PS-WinGet_Apps_To_Install.ps1
winget install Microsoft.dotnet
winget install Microsoft.PowerShell
winget install Microsoft.WindowsTerminal
winget install Postman.Postman
winget install Notepad++.Notepad++
winget install Telerik.Fiddler
winget install Microsoft.VisualStudioCode
winget install Microsoft.VisualStudio.Enterprise
winget install Microsoft.Powertoys
winget install microsoft.mousewithoutborder
@BrianTJackett
BrianTJackett / EXO-New_SCCeDiscoveryCaseAndHold.ps1
Last active Sep 13, 2020
Create an Office 365 Security and Compliance Center eDiscovery case, hold, and content search. Warning: uses basic authentication which will be deprecated in Oct 2020.
View EXO-New_SCCeDiscoveryCaseAndHold.ps1
Set-StrictMode -Version "Latest"
# eDiscovery case creation
$caseName = 'Smith v. Johnson';
$UPN = 'user1@contoso.onmicrosoft.com', 'user2@contoso.onmicrosoft.com'
$description = "$caseName"
$policyName = "$caseName - Hold Policy"
$ruleName = "$caseName - Hold Rule"
$searchName = "$caseName - Search Name"
$rootFolderNameQuery = "Legal Hold"
@BrianTJackett
BrianTJackett / PS-O365_admin_creds.ps1
Created Nov 15, 2019
This snippet will store credentials for 2 different accounts encrypted to disk. They will then be loaded into PSCredentials as global variables. Place this in your profile for automatic loading.
View PS-O365_admin_creds.ps1
New-PSDrive -Name Scripts -PSProvider FileSystem -Root <folderLocationOfScriptsGoesHere>
#read-host -AsSecureString -Prompt "Enter O365 password 1" | ConvertFrom-SecureString | set-content scripts:\O365AdminPassword1.txt
#read-host -AsSecureString -Prompt "Enter O365 password 2" | ConvertFrom-SecureString | set-content scripts:\O365AdminPassword2.txt
function Import-O365AdminCredential
{
$smtpAddress1 = "admin@m365x974797.onmicrosoft.com"
$CredsFile1 = "Scripts:\O365AdminPassword1.txt"
@BrianTJackett
BrianTJackett / WT-profiles.json
Last active Jul 20, 2020
Windows Terminal settings.json file with included shells (profiles) for PowerShell v7, Zsh, and more.
View WT-profiles.json
// This file was initially generated by Windows Terminal 1.0.1811.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@BrianTJackett
BrianTJackett / PS-Get_PowerApps_App_Connections.ps1
Created Mar 14, 2019
Iterate through all environments and get all PowerApps apps and the connections they use.
View PS-Get_PowerApps_App_Connections.ps1
Add-PowerAppsAccount
$environments = Get-PowerAppEnvironment
foreach($environ in $environments.EnvironmentName)
{
$apps = Get-AdminPowerApp -EnvironmentName $environ
$apps | Add-Member -MemberType ScriptProperty -Name Connections -Value {$this.internal.properties.connectionReferences.PSObject.Properties.Value.DisplayName} -Force
$apps | Select-Object AppName, DisplayName, Connections
}
View CS-Graph_Request_Users_GraphServiceClient.cs
var graphResult = graphClient.Users.Request().GetAsync().Result;
Console.WriteLine(graphResult[0].DisplayName);
@BrianTJackett
BrianTJackett / CS-Graph_Class_MsalAuthenticationProvider.cs
Last active Oct 7, 2019
Microsoft Graph create class to handle authentication with Azure AD and use access token on subsequent requests.
View CS-Graph_Class_MsalAuthenticationProvider.cs
public class MsalAuthenticationProvider : IAuthenticationProvider
{
private IConfidentialClientApplication _clientApplication;
private string[] _scopes;
public MsalAuthenticationProvider(IConfidentialClientApplication clientApplication, string[] scopes) {
_clientApplication = clientApplication;
_scopes = scopes;
}
@BrianTJackett
BrianTJackett / CS-Graph_Prepare_GraphServiceClient.cs
Last active Oct 7, 2019
Microsoft Graph C# .Net Core prepare GraphServiceClient
View CS-Graph_Prepare_GraphServiceClient.cs
var clientId = "<AzureADAppClientId>";
var clientSecret = "<AzureADAppClientSecret>";
var redirectUri = "<AzureADAppRedirectUri>";
var authority = "https://login.microsoftonline.com/<AzureADAppTenantId>/v2.0";
var cca = ConfidentialClientApplicationBuilder.Create(clientId)
.WithAuthority(authority)
.WithRedirectUri(redirectUri)
.WithClientSecret(clientSecret)
.Build();
@BrianTJackett
BrianTJackett / PS-Get_All_Sites_SPO.ps1
Created Jul 31, 2018
Get all sites from SharePoint Online using SPO Management Shell commands.
View PS-Get_All_Sites_SPO.ps1
Connect-SPOService -Url '<tenantAdminUrl>'
Get-SPOSite -Limit all -IncludePersonalSite $true
@BrianTJackett
BrianTJackett / CS-CSOM_Traverse_All_Sites_SPO.txt
Last active Jul 1, 2019
Traverse all sites in SharePoint Online using C# CSOM.
View CS-CSOM_Traverse_All_Sites_SPO.txt
List <SiteProperties> list = new List <SiteProperties>();
SPOSitePropertiesEnumerable ssp = null;
SPOSitePropertiesEnumerableFilter sspFilter = new SPOSitePropertiesEnumerableFilter();
SharePointOnlineCredentials creds = new SharePointOnlineCredentials("myUsernameGoesHere", securePassword);
using (ClientContext cc = new ClientContext("myURLGoesHere"))
{
cc.Credentials = creds;