Skip to content

Instantly share code, notes, and snippets.

View SweetAsNZ's full-sized avatar
🏠

Tim West SweetAsNZ

🏠
View GitHub Profile
@SweetAsNZ
SweetAsNZ / Get-UPN.ps1
Created December 7, 2022 01:14
Get UPN User Principal Name/UserPrincipalName
# Requires no Active Directory Module or rights.
$UPN = (([ADSISEARCHER]"samaccountname=$($env:USERNAME)").Findone().Properties).userprincipalname ; $UPN
@SweetAsNZ
SweetAsNZ / Connect-Exchange.ps1
Created December 7, 2022 01:12
Connect to Exchange Online and Pass Your UPN
function Connect-Exchange
{
$UPN = (([ADSISEARCHER]"samaccountname=$($env:USERNAME)").Findone().Properties).userprincipalname ; $UPN
Connect-ExchangeOnline -UserPrincipalName $UPN -ShowProgress $true
}
@SweetAsNZ
SweetAsNZ / Get-VeeamJobSizes.ps1
Created December 2, 2022 04:12
Get Veeam Job Sizes
. C:\SCRIPTS\VEEAM\Connect-Veeam\Connect-Veeam.ps1 # Load the Connect Veeam Function
Connect-Veeam -VeeamServer $ENV:COMPUTERNAME
$JobSizes = Get-VBRBackup | Select @{N="Job Name";E={$_.Name}}, @{N="Size (GB)";E={[math]::Round(($_.GetAllStorages().Stats.BackupSize |
Measure-Object -Sum).Sum/1GB,1)}}
$JobSizes | Format-Table -AutoSize
$JobSizes | Export-CSV -NoTypeInformation $OutJobSizes
@SweetAsNZ
SweetAsNZ / MyVeeamReport.ps1
Created December 2, 2022 03:17
Gets All The Info From Veeam
#Requires -Version 3.0
#Requires -PSEdition Desktop
#Requires -Module @{ModuleName="Veeam.Backup.PowerShell"; ModuleVersion="1.0"}
<#
.SYNOPSIS
My Veeam Report is a flexible reporting script for Veeam Backup and
Replication.
.DESCRIPTION
My Veeam Report is a flexible reporting script for Veeam Backup and
<#
.SYNOPSIS
Deploy Multiple VMs to vCenter
.DESCRIPTION
VMs are deployed asynchronously based on a pre-configured csv file (DeployVM.csv)
.PARAMETER csvfile
Path to DeployVM.csv file with new VM info
@SweetAsNZ
SweetAsNZ / Check-ServerBackup.ps1
Last active November 23, 2022 22:30
Check if a Server is Being Snapshotted in a Veeam backup and What Job a Server is Being Backed up In
<#
.Synopsis
Checks Veeam Snapshot Backups For A Given Server Name. Also finds the Job that Server is being snapped in
.DESCRIPTION
.EXAMPLE
Check-ServerBackup -ComputerName Server01
.EXAMPLE
Check-ServerBackup -ConnectVeeamServer:$true -ReloadQuery:$true -ComputerName Server02
#>
@SweetAsNZ
SweetAsNZ / Get-VMHostManagementNetwork
Created November 8, 2022 03:00
Get ESX Host Management Network IP's
<#
.Synopsis
Connect to ESX Hosts and Get Mgt IP and Test Connectivity if requested
.DESCRIPTION
.EXAMPLE
Get-VMHostManagementNetwork -VIServer 'vc.domain1.local' -VMHost 'ESX01.domain1.local'
.EXAMPLE
Get-VMHostManagementNetwork -VIServer 'vc2.domain1.local'
#>
@SweetAsNZ
SweetAsNZ / Get-VMwareServersAndVeeamBackedUpServers.ps1
Created October 2, 2022 21:38
Compare VMware Guests and Servers Backed Up By Veeam - Get A List of Servers That Aren't Backed Up
# Query VMWare for the List of All servers and compare with Veeam backups to see coverage
$Date = ((Get-Date -Format "yyyy-MM-dd_HHmm_K").Replace(":","-").Replace("+","-")).ToString() # _$($Date).csv" _$($Date).txt" # Date for use in Filenames with TZ
function Connect-VMWare{
$Server = 'vcenter'
$VMCli = (Get-Module VMware.PowerCLI -ListAvailable).Name
if($VMCli -ne 'VMware.PowerCLI'){
<#
.Synopsis
Gets information of a port number
.DESCRIPTION
Function provides detailed information of port numbers, like - the service which use the port, Transport protocol and a small decsription.
.EXAMPLE
PS > Get-Port -Port 20,21,53
Port Service Protocol Description
---- ------- -------- -----------
@SweetAsNZ
SweetAsNZ / Remove-PhishingEmail.ps1
Last active September 14, 2022 01:39
Remove A Phishing Email From Exchange Online
function Remove-PhishingEmail
{
# "A maximum of 10 items per mailbox can be removed at one time"
# REF: https://docs.microsoft.com/en-us/microsoft-365/compliance/search-for-and-delete-messages-in-your-organization?view=o365-worldwide
#"Hard-deleted messages are marked for permanent removal from the mailbox and will be permanently removed the next time the mailbox is processed by the Managed Folder Assistant" REF: https://docs.microsoft.com/en-us/microsoft-365/compliance/search-for-and-delete-messages-in-your-organization?view=o365-worldwide
#"The goal is to process mailboxes at least once weekly. Experience is that MFA usually performs better than this and that you can expect to have mailboxes processed twice a week" REF: https://office365itpros.com/2018/12/10/reporting-the-managed-folder-assistant/