Get all DNS Zones and Records in CSV

$results = Get-DnsServerZone | % {

    $zone = $_.zonename

    Get-DnsServerResourceRecord $zone | select @{n=’ZoneName’;e={$zone}}, HostName, RecordType, @{n=’RecordData’;e={if ($_.RecordData.IPv4Address.IPAddressToString) {$_.RecordData.IPv4Address.IPAddressToString} else {$_.RecordData.NameServer.ToUpper()}}}

}

$results | Export-Csv -NoTypeInformation c:\temp\DNSRecords.csv -Append

Add/Update DNS servers for Azure VM

Log onto Azure > Find VM > Operations, Run Command > Run PowerShell Script

Get-NetAdapter | Select-Object InterfaceAlias , InterfaceIndex

Take a note of the InterfaceIndex

Get-DnsClientServerAddress -InterfaceIndex 7

Checks current DNS servers.

Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses (“10.215.153.11″,”168.63.129.16″,”10.230.160.15”)

Sets DNS servers

Register-DnsClient

PS equivalent of Ipconfig /registerDNS

Get-DnsClientServerAddress -InterfaceIndex 7

Check interface for new DNS servers

Assign full permissions for a user to another users calendar

Cannot assign folder permissions in mixed hybrid environment i.e. cannot grant a M365 user calendar permissions to an On-Prem 2016 mailbox or vice versa.

john@contoso.com is the calendar being shared
scahill@xyz or dirk@contoso.de is the person who is being granted permission

Get Existing Permissions

Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar

If user is not English speaking get calendar or other folder local name using
Get-MailboxFolderStatistics -Identity dirk@contoso.de -FolderScope Calendar

Get the existing permissions using the local calendar name
Get-MailboxFolderPermission -Identity dirk@contoso.de\Kalendar

Grant Edit Permissions

Set-MailboxFolderPermission -Identity john@contoso.com:\Calendar-User <alias> -AccessRights Editor

Grant Manage Permissions

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User scahill@xyz -AccessRights Editor -SharingPermissionFlags Delegate,CanViewPrivateItems

Note -SharingPermissionFlags is cloud only

Grant Free/Busy Permissions Only

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -AccessRights AvailabilityOnly -User scahill@xyz.com

Grant Read-Only Permissions

Add-MailboxFolderPermission -Identity john@contoso.com:\Calendar -AccessRights Reviewer -User scahill@xyz.com

Grant Limited Details Permissions

Set-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User normilg -AccessRights Editor – scahill@xyz.com -SharingPermissionFlags Delegate,CanViewPrivateItems

Remove Permissions

Remove-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User scahill@xyz.com

Calendar Sharing Rights aka Access Rights

Author: CreateItems, DeleteOwnedItems, EditOwnedItems, FolderVisible, ReadItems

Contributor: CreateItems, FolderVisible

Editor: CreateItems, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderVisible, ReadItems

None: FolderVisible

NonEditingAuthor: CreateItems, FolderVisible, ReadItems

Owner: CreateItems, CreateSubfolders, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderContact, FolderOwner, FolderVisible, ReadItems

PublishingEditor: CreateItems, CreateSubfolders, DeleteAllItems, DeleteOwnedItems, EditAllItems, EditOwnedItems, FolderVisible, ReadItems

PublishingAuthor: CreateItems, CreateSubfolders, DeleteOwnedItems, EditOwnedItems, FolderVisible, ReadItems

Reviewer: FolderVisible, ReadItems

Set “Out of Office” on Mailbox with PowerShell

Dates are 6th April 2021 to 7th April 2021 and are always in American format (mm/dd/yyyy)

Uses email address

Set-MailboxAutoReplyConfiguration -identity mary.raymond@XYZ.com -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021 08:00:00” -ExternalAudience all -InternalMessage $message -ExternalMessage $message

Set-MailboxAutoReplyConfiguration -identity Emma.johnson@xyz.co.uk -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021” -ExternalAudience all -InternalMessage “I am currently out the office and will be returning on 7th April 2021.” -ExternalMessage “I am currently out the office and will be returning on 7th April 2021.”

Uses mail alias

Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState enabled -ExternalAudience all -InternalMessage “This email address is no longer in use. Please email jimmy.parker@XYZ.com, Thanks” -ExternalMessage “This email address is no longer in use. Please email jimmy.parker@XYZ.com, Thanks”

Set-MailboxAutoReplyConfiguration <alias> -AutoReplyState scheduled -starttime “04/06/2021” -endtime “04/07/2021” -ExternalAudience all -InternalMessage “I’m currently out of the office and this mailbox is not being monitored. If you have any queries which need responding to please contact my manager Mark Mende by email mark.mende@xyz.co.uk” -ExternalMessage “I’m currently out of the office and this mailbox is not being monitored. If you have any queries which need responding to please contact my manager Mark Bloggs by email mark.bloggs@xyz.co.uk

If part of the message has a $ sign – Use single quotes instead of double quotes

Set-MailboxAutoReplyConfiguration -identity risk@xyz.com -AutoReplyState enabled -ExternalAudience all -InternalMessage  ‘Thank you for your mail. Please note that this is an unmonitored mail box. Please redirect your mail to $Risk@xyz.com‘ -ExternalMessage ‘Thank you for your mail. Please note that this is an unmonitored mail box. Please redirect your mail to $Risk@xyz.com

To check your results afterwards: 

Get-MailboxAutoReplyConfiguration –Identity  servicing@xyz.co.uk

To turn off auto-replies

Set-MailboxAutoReplyConfiguration -Identity <alias or email> -AutoReplyState disabled

To turn off auto-replies and clear the reply text

Set-MailboxAutoReplyConfiguration <alias or email> –AutoReplyState Disabled –ExternalMessage $null –InternalMessage $null

HTML Multiline Message, use <br> tags for line breaks

Set-MailboxAutoReplyConfiguration -identity <alias or email> -AutoReplyState enabled -ExternalAudience all -InternalMessage “This mailbox is currently closed and is not monitored.<br><br>Please contact the Service Desk using your company’s number below..<br><br>XYZ Europe: +01 123 456 7890 <br><br>Alternatively  please log your issue on Service Desk Online through your company Intranet.” -ExternalMessage “”This mailbox is currently closed and is not monitored.<br><br>Please contact the Service Desk using your company’s number below..<br><br>XYZ Europe: +01 123 456 7890 <br><br>Alternatively  please log your issue on Service Desk Online through your company Intranet.”

Geodesic Dome Greenhouse

Planning

Now that I’ve moved back to the country I’ve got plans for all sorts of projects. The first one is building a Geodesic Dome Greenhouse from timber.

I’ve spent the past 6 weeks resarching

  • Sizes: settled on 8 meter diameter
  • Build: kit or DIY. Settled on DIY
  • Glazing struts: wood, plastic pipe or tubular metal.
  • Joints and Hubs: DIY hubs, off-the-shelf hubs, no hubs.
  • Glazing: triple-wall poly-carbonate, polyethylene,
  • Raised beds: materials, height, width.
  • Foundations: concrete piers, slab
  • Internal Paths: width, materials.
  • Insulation: north wall insulation types, ground insulation, glazing.
  • Orientation: door will face north.
  • Double doors: keeping drafts out.
  • Vermin control: keeping mice and other beasties out.
  • Passive heating and cooling: GAHT, thermal vents, thermal mass.
  • Direct heating: wood chip composting, wind turbines.
  • Wood preservatives: Leitrim is usually very damp , organic material rots very fast.
  • Wood working tools: table saw, mitre saw, digital protractors, staplers, screws, etc.
  • Wood Type and Sizes: Species, planed, rough, treated, suppliers.
  • Maintenance: Does the build allow to easily repair the structure and individual glazing panels.

I’ve settled on a hub system from Geosota in Russia. Plans have arrived, I’m waiting on the hubs.

To buy: planed 4 x 2, paint, concrete, rebar, post shoes.

Future: Polytunnel plastic, I’d like to get the bubble wrap stuff if possible. Maybe some polycarbonate. Insulation. Soil insulation.

PowerShell: Capture Network Traces

<#
.SYNOPSIS
Capture Traces with Wireshark in PowerShell

.DESCRIPTION

#############################################################
# #
# Capture network traces in PowerShell #
# Circular tracing #
# #
# #
# #
# (C)Citrix EMEA Escalation Team #
# #
# David Cristobal #
# #
#############################################################

Script to automate tracing with Wireshark using PowerShell, when GUI cannot be used

CaptureNetworkTraces.ps1 -FileName <[string]> -WiresharkPath <[string]> -NumberOfFiles <[string]> -FileSize <[string]> -TimeToStart <[string]> -RecheckTime <[string]> -CircularTraces

-FileName <File Name>
Name for the files, If null, will use the computer’s name and the date

-WiresharkPath <Wireshark installation path>
As this script relies in Wireshark binaries, the path is needed. If it’s installed in a different drive, you can specify it with this parameter

-NumberOfFiles <>
Number of files. If none given, will use 5

-FileSize
Size of every file in Kb. If none is given, will use 100Mb

-TimeToStart
Time to start tracing in format HHMM (like 2230 for 23:30 or 0845 for 8:45)

-RecheckTime
In case delayed start set, interval to check if the time has yet reached in seconds

-CircularTraces
Set traces as circular, ring buffer

.EXAMPLE
CaptureNetworkTraces.ps1 -FileName Trace001 -NumberOfFiles 4

Capture 4 files named Trace001.pcapng to Trace004.pcapng, 100Mb each (default value)

.EXAMPLE
CaptureNetworkTraces.ps1 -FileName Trace001 -FileSize 10000 -CircularTraces

Capture 5 files (default value) named named Trace001.pcapng to Trace005.pcapng, 10Mb each, in circualr tracing (until Ctrl+C is pressed)

.EXAMPLE
CaptureNetworkTraces.ps1 -NumberOfFiles 10 -FileSize 10000 -TimeToStart 2230 -RecheckTime 60

Capture 10 files 10Mb each with name ServerDate.pcapng (default), starting the trace at 22:30 and checking it every 60 seconds

#>

##Paramaters for the script
param
(
[Parameter(Mandatory=$false)][string]$FileName,
[Parameter(Mandatory=$false)][string]$WiresharkPath,
[Parameter(Mandatory=$false)][string]$NumberOfFiles,
[Parameter(Mandatory=$false)][string]$FileSize, ## In Kb
[Parameter(Mandatory=$false)][string]$TimeToStart, ## Format HHmm (Hours, minutes)
[Parameter(Mandatory=$false)][string]$RecheckTime, ## In seconds
[Parameter(Mandatory=$false)][switch]$CircularTraces ## Circular tracing
)

#region Variables
$Delay=$False
#endregion

#region Sanity checks

## Check if Filename is provided
if (!$FileName) ## If Filename is not provided, generate one withe date and time
{
$Filename=($env:computername)+”-“+(Get-Date -format yyyyMMdd-HHmmss)
}

$Filename=$Filename+”.pcapng” ## Add the Wireshark extension ot the file

## Check if Number of files is set
if (!$NumberOfFiles) ## If not set, 5 by default
{
$NumberOfFiles=”5″
}

## Check if Size of files is set
if (!$FileSize) ## If not set, 100Mb by default
{
$FileSize=”100000″
}

## Check if time to start is set is set
if (![string]::IsNullOrEmpty($TimeToStart))
{
if ((![string]::IsNullOrEmpty($TimeToStart)) -AND ($TimeToStart.Length -eq 4) -AND ($TimeToStart -match ‘[0-9]{4}’) -AND ([convert]::ToInt32($TimeToStart,10) -lt “2400”))
{
Write-host “Delayed start set for “$TimeToStart.Substring(0,2)”:”$TimeToStart.Substring(2,2)
$Delay=$true
Write-host “`n”

## Check if time to recheck delayed start is set
if ((![string]::IsNullOrEmpty($RecheckTime)) -AND ([Helpers]::IsNumeric($RecheckTime)))
{
Write-host “Timeout to recheck delayed start set to $RecheckTime seconds”
}
else
{
Write-host “Timeout to recheck delayed start not set”
Write-host “Default to 1 minute, 60 seconds”
$RecheckTime=60
}
}
else
{
Write-host “Incorrect time to start the trace” -foregroundcolor red
Write-host “Time needs to be set as HHmm (Hours,Minutes) and less that 2400”
Write-host “`n”
exit
}
}

## Check if Wireshark is installed
if (!$WiresharkPath) {$WiresharkPath = “C:\Program Files\Wireshark”}

if (Test-Path $WiresharkPath)
{
Write-Host “Wireshark found in the machine”
Write-host “`n”
}
else
{
Write-Host “Wireshark is not installed in the machine!!!” -foregroundcolor red -backgroundcolor yellow
Write-Host “If it’s not installed in the default path, use the -WiresharkPath parameter” -foregroundcolor red -backgroundcolor yellow
Write-Host “Stopping script” -foregroundcolor red -backgroundcolor yellow
Write-host “`n”
Write-host “Press Any Key To Exit….”
cmd /c pause | out-null
exit
}

# Verification and creation of the tshark Alias
if(Get-alias -name tshark*)
{
Write-Host “Tshark alias exists”
Write-host “`n”get-help
}
else
{
Write-Host “Tshark alias doesn’t exist. Creating it…”
new-alias tshark $WiresharkPath’\tshark.exe’
Write-host “Tshark alias created”
Write-host “`n”
}

# Verify if Wireshark path in the Path variable and adding it if needed
if($env:Path -like ‘*’+$WiresharkPath+’*’)
{
Write-Host “Wireshark path already in path variable”
Write-host “`n”
}
else
{
Write-Host “Wireshark path not found in Path variable. adding it…”
$env:Path += “;C:\Program Files\Wireshark\”
Write-Host “Wireshark path added”
Write-host “`n”
}

# Check if the trace is circular

if ($CircularTraces)
{
$CircularFlag = “-b”
}

#endregion

#region Wrap up parameters and show them on screen
Write-Host “Parameters for the trace” -foregroundcolor DarkRed
Write-Host “========================” -foregroundcolor DarkRed
Write-Host “Filename that will be used: ” -foregroundcolor green -nonewline
Write-Host $FileName -foregroundcolor gray
Write-Host “Number of files that will be kept: ” -foregroundcolor green -nonewline
Write-Host $NumberOfFiles -foregroundcolor gray
Write-Host “Size of every file: ” -foregroundcolor green -nonewline
Write-Host ($FileSize/1000)”Mb” -foregroundcolor gray
Write-Host “Path for Wireshark: ” -foregroundcolor green -nonewline
Write-Host $WiresharkPath -foregroundcolor gray
Write-host “`n”
Write-host “To stop the trace at any time, press Ctrl + C” -foregroundcolor red
Write-host “`n”
#endregion

#region Capture traces

## Check delayed start
while (($Delay -eq $True) -AND ((Get-Date -format HHmm) -ne $TimeToStart))
{
Write-Host “Time to start tracing not reached yet.”
Write-host “Actual time”(Get-Date -format HHmmss)
Write-Host “Expected time to start: “$TimeToStart
Start-Sleep -s $RecheckTime
}

## Start tshark with parameters
tshark.exe -w $FileName $CircularFlag filesize:$FileSize -b files:$NumberOfFiles

#endregion

Exit mobile version
%%footer%%