Skip to content

Instantly share code, notes, and snippets.

@kbhunut
kbhunut / DumpMailboxEmail.ps1
Last active January 6, 2022 22:09
Script to dump email from an exchange Mailbox using EWS. This is script from 2014
Import-Module -Name 'C:\PowerShell\Modules\EWSModule\EWSModule.psm1'
###Requires -Modules EWSModule
function Get-cDumpMailboxEmail
{
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true,
Position = 0)]
$OutputPathRoot,
[pscredential]
@kbhunut
kbhunut / update_ad_user.ps1
Created April 5, 2020 17:14
Update AD User Object Information
# First you need RSAT tool with Active Directory Powersell Module installed on your local machine
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/?view=win10-ps
# Get user in AD
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-aduser?view=win10-ps
Get-ADuser [email protected]
# Set info for user in AD
# https://docs.microsoft.com/en-us/powershell/module/addsadministration/set-aduser?view=win10-ps
Get-ADuser [email protected] | Set-ADUser -OfficePhone "555-555-1234" -Manager (Get-ADuser [email protected])
@kbhunut
kbhunut / o365_Onboarding.ps1
Last active March 31, 2025 12:35
Office 365 Onboarding
#Requires -Version 7.0
# If you powershell version is lower than 7. Must update to the latest version.
# Install Azure Graph Powershell Module
# Run this Command: Install-Module -Name AzureAD
# https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell#connect-with-the-azure-active-directory-powershell-for-graph-module
# https://docs.microsoft.com/en-us/office365/enterprise/powershell/manage-user-accounts-and-licenses-with-office-365-powershell
$Credential = Get-Credential
Connect-AzureAD -Credential $Credential
# Tried of input credential every time? You can export credential and import it.
@kbhunut
kbhunut / exch_onboarding.ps1
Created April 5, 2020 16:16
New Exchange Users Onboarding
# Create Mailbox via Powershell
# https://docs.microsoft.com/en-us/exchange/recipients/create-user-mailboxes?view=exchserver-2019
# https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/new-mailbox?view=exchange-ps
$defaultPassword = ConvertTo-SecureString -String 'Pa$$word1' -AsPlainText -Force
New-Mailbox -Name "Pilar Pinilla" -UserPrincipalName [email protected] -Password -FirstName 'Pilar' -LastName 'Pinilla' -ResetPasswordOnNextLogon $true -OrganizationalUnit "OU=NYC,DC=Contoso,DC=Com"
# How to do in Bulk Create via CSV
# CSV Header - Name,FirstName,LastName,UserPrincipalName,OU
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-7