Skip to content

Instantly share code, notes, and snippets.

View junecastillote's full-sized avatar

June Castillote junecastillote

View GitHub Profile
@junecastillote
junecastillote / Office365TokenGet.psm1
Last active July 8, 2019 02:32
PowerShell Function to get Microsoft Graph API token using your app's client ID, client Secret and Tenant Domain
Function New-MSGraphAPIToken {
<#
.SYNOPSIS
Acquire authentication token for MS Graph API
.DESCRIPTION
If you have a registered app in Azure AD, this function can help you get the authentication token
from the MS Graph API endpoint. Each token is valid for 60 minutes.
#REGION VARIABLES
#// username (domain\username)
$uname = "domain\user"
#password - plain text
$passwd = "p@ssw0rd"
#// remote computer where the files to be copied are hosted
$remoteSourceComputer = "server01"
#// source folder from the remote computer (DO NOT USE UNC PATH)
$remoteSourceFolder = "C:\SourceFolder"
#// destination folder on the local machine
@junecastillote
junecastillote / Get-SelectedMailboxProperties.ps1
Last active March 18, 2019 14:08
Combining Selected Properties of Two Objects into a New Array using PowerShell
#create an empty array for the final result
$finalResult = @()
#get mailboxes as per your requirement
$mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Sort-Object UserPrincipalName
#loop through each object
foreach ($mailbox in $mailboxes) {
Write-Host "Reading:" $mailbox.UserPrincipalName
@junecastillote
junecastillote / Export-PowerBIWorkSpaceListToCSV.ps1
Last active May 14, 2019 12:48
PowerBI Workspace List Export
#must have MicrosoftPowerBIMgmt module installed (Install-Module -Name MicrosoftPowerBIMgmt)
#must have PowerBI Admin rights
#must be connected to PowerBI as admin
$credential = Get-Credential
Connect-PowerBIServiceAccount -Credential $credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
$pbws = Get-PowerBIWorkspace -Scope Organization -ALL | Sort-Object Name
' Output file for report
fileOutput = "Allow_RelayIP.txt"
' The Vitual SMTP Server ID
vistualSMTPServer = "IIS://localhost/smtpsvc/1"
Set fso = CreateObject("Scripting.FileSystemObject")
Set allowFile = fso.opentextfile(fileOutput,2,true)
Set objSMTP = GetObject(vistualSMTPServer)
Set objRelayIpList = objSMTP.Get("RelayIpList")
@junecastillote
junecastillote / GetIISSMTPRelayIP.ps1
Last active June 1, 2023 16:01
Get IIS SMTP Server Relay IP Address List
Function GetIISSmtpRelayIPList {
param (
# virtual smtp server name
[parameter()]
[string]$smtpName = "SmtpSVC/1",
# computer name
[parameter()]
[string]$computerName = $env:COMPUTERNAME
)
Function Get-MSGraphOAuthToken {
<#
.SYNOPSIS
Acquire authentication token for MS Graph API
.DESCRIPTION
If you have a registered app in Azure AD, this function can help you get the authentication token
from the MS Graph API endpoint. Each token is valid for 60 minutes.
@junecastillote
junecastillote / List-ShellNameSpace.ps1
Created January 2, 2020 13:36
List all Shell Application Namespace in Windows
$ShellApp = New-Object -ComObject ShellApp.Application # initialize the COM application object
foreach($i in $(0..100)){ # from 0 to 100. The highest number is just a guess.
$ShellApp.namespace($i) | Where-Object {$_.Title} | # try the namespace, and return only if there's value in title
Select-Object `
@{n="Dec";e={$i}}, ` # Base 10 (Dec) namespace index
@{n="Hex";e={"0x" + ('{0:X}' -f $i)}}, ` # Base 16 (Hex) namespace index
Title, `
@{N="Path";e={$_.Self.Path} } # Folder path
}
@junecastillote
junecastillote / Get-MembersRecursive.ps1
Last active January 7, 2020 01:44
Function to recursively list group members (nested)
## Function to recursively list group members (nested)
Function Get-MembersRecursive {
param (
[parameter()]
[string]$RecipientName
)
$groupMembers = @()
$group = Get-Group $RecipientName -ErrorAction SilentlyContinue
foreach ($groupMember in $group.Members) {
$memberObj = Get-Recipient $groupMember -ErrorAction SilentlyContinue
@junecastillote
junecastillote / button.js
Created September 16, 2020 12:25
Example of a Static Website
// button.js
var btn = document.querySelector('button')
btn.addEventListener('click', function() {
document.querySelector('p').style.display = 'block'
})