Skip to content

Instantly share code, notes, and snippets.

View frankhu-2021's full-sized avatar

Frank Hu frankhu-2021

View GitHub Profile
@frankhu-2021
frankhu-2021 / LocalizationXML(NotComplete)
Created February 6, 2020 20:33
B2C Localization XML Code
XML - Localization
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="Append">
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>es</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_subject">Contoso account email verification code</LocalizedString>
@frankhu-2021
frankhu-2021 / UserName_EmailAddress_AzureRoles_Report.ps1
Created November 8, 2019 03:08
Returns users full name, email address, and azure role in your tenant and prints them out in a csv format. You need to connect-azuread first before running this powershell script.
$myuser = get-azaduser
$mygroups = get-azadgroup
$myReport = New-Object System.Collections.ArrayList($null)
$myReport.AddRange($myuser)
for($i =0; $i -lt $myuser.length; ++$i){
$fullname = $myuser.Get($i).displayname;
$emailaddress = $myuser.get($i).userprincipalname;
$azurerole = Get-AzRoleAssignment -ObjectId $myuser.Get($i).id
@frankhu-2021
frankhu-2021 / List_All_Definitions_Az_Roles.PS
Created September 20, 2019 22:59
This PowerShell script will list all the definitions from the Azure RBAC role that you put in the -name parameter.
Get-AzRoleDefinition -name "<Insert-Your-Azure-RBAC-Role>" | `
%{
$a = $_
$_.Actions | select `
@{n="Role";e={$a.Name}},
@{n="Type";e={"Actions"}},
@{n="Definition";e={$_}}
$_.DataActions | select `
@{n="Role";e={$a.Name}},
@{n="Type";e={"DataActions"}},
@frankhu-2021
frankhu-2021 / HTML Select Drop Down
Last active July 31, 2019 19:13
A dropdown list of HTML for each State
<select onChange="window.location.href=this.value">
<option>Select Your State </option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
@frankhu-2021
frankhu-2021 / UpgradeApachePHP.sh
Last active April 24, 2019 03:05
Update PHP version for Ubuntu Machines with Apache2
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2
sudo apt-get install php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-mcrypt php7.2-zip php7.2-fpm
sudo a2dismod <old-php-version>
sudo a2enmod php7.2
sudo service apache2 restart
@frankhu-2021
frankhu-2021 / Get All AAD Policies for SP
Created March 14, 2019 20:07
This gist is a powershell script utilizing AzureAD Preview to get the claims mapping policies for a service principal.
Connect-AzureAD
Import-Module "AzureADPreview"
$appID = "...guid-of-the-AppID..."
$sp = Get-AzureADServicePrincipal -Filter "servicePrincipalNames/any(n: n eq '$appID')"
$existingPolicies = Get-AzureADServicePrincipalPolicy -Id $sp.ObjectId `
| Where-Object { $_.Type -eq "ClaimsMappingPolicy" }
$existingPolicies
connect-azuread
$appname = "Your-App-Registration-Name"
$sp = Get-AzureADServicePrincipal -filter "DisplayName eq '$appname'"
$role = Get-AzureADDirectoryRole
For ($i=0; $i -lt $role.Count; $i++){
connect-azuread
$SPObjectID = "your-spn-objectid"
$role = (Get-AzureADDirectoryRole).objectId
For ($i=0; $i -lt $role.Count; $i++){
if(Get-AzureADDirectoryRoleMember -ObjectId $role.Get($i) | where {$_.objectId -eq $SPObjectID}) {
$role.DisplayName
}
}
@frankhu-2021
frankhu-2021 / Regex for Phone numbers
Created January 6, 2019 01:44
Regex for Phone numbers
1. xxx-xxx-xxxx grep -o '[0-9]\{3\}\-[0-9]\{3\}\-[0-9]\{4\}' file.txt
2. (xxx)xxx-xxxx grep -o '([0-9]\{3\})[0-9]\{3\}\-[0-9]\{4\}' file.txt
3. xxx xxx xxxx grep -o '[0-9]\{3\}\s[0-9]\{3\}\s[0-9]\{4\}' file.txt
4. xxxxxxxxxx grep -o '[0-9]\{10\}' file.txt
grep -o '\([0-9]\{3\}\-[0-9]\{3\}\-[0-9]\{4\}\)\|\(([0-9]\{3\})[0-9]\{3\}\-[0-9]\{4\}\)\|\([0-9]\{10\}\)\|\([0-9]\{3\}\s[0-9]\{3\}\s[0-9]\{4\}\)' file.txt
- Found online, and put on my git for reference.
Credit goes to Raullen Chai
on
@frankhu-2021
frankhu-2021 / CreateRandomUsers
Created November 4, 2018 03:10
This method will create users for a test tenant in order to test paging, or if you're trying to do some sort of testing.
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Net.Http.Headers;
using System.Net.Http;
static async Task createRandomUsers()
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
Console.WriteLine("\n \n Creating users {0}", DateTime.Now.ToString());
for(int index = 0;index < 10; ++index)