Skip to content

Instantly share code, notes, and snippets.

View AshFlaw's full-sized avatar

AshFlaw

  • The Full Circle
View GitHub Profile
@AshFlaw
AshFlaw / install-GPMC.ps1
Created August 15, 2018 16:42
Install Group Policy Management Console, GPMC via PowerShell
Install-WindowsFeature –Name GPMC
@AshFlaw
AshFlaw / CopyADGroupMemberships.ps1
Created July 19, 2018 08:17
Copy AD group memberships from one user account to another.
$Source = ""
$Destination = ""
Get-ADUser -Identity $Source -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members $Destination
@AshFlaw
AshFlaw / EOL-MailBoxAuditing.ps1
Created July 19, 2018 08:16
Check, enable and disable Tenant level mailbox auditing in Exchange Online
# Get Auditing Status
Get-OrganizationConfig | Select AuditDisabled
# Disable Auditing for Tenant
Set-OrganizationConfig -AuditDisabled $True
# Disable Auditing for User
Set-MailboxAuditBypassAssociation -Identity $User -AuditBypassEnabled $True
# Find Mailboxes with Audting Disabled
@AshFlaw
AshFlaw / Set-EolMailBoxAuditEnabledAll.ps1
Created July 19, 2018 06:48
Enable Exchange Online mailbox auditing manually for all mailboxes
Get-Mailbox -Filter {AuditEnabled -eq $False} -RecipientTypeDetails UserMailbox, SharedMailbox | Set-Mailbox -AuditEnabled $True –AuditDelegate Create, FolderBind, SendAs, SendOnBehalf, SoftDelete, HardDelete, Update, Move, MoveToDeletedItems, UpdateFolderPermissions
@AshFlaw
AshFlaw / Get-AvailableRAM.ps1
Created July 17, 2018 09:13
Get available RAM on a remote server via powershell
$Server = ""
(Get-Counter -Counter "\Memory\Available MBytes" -ComputerName $Server).CounterSamples[0].CookedValue
@AshFlaw
AshFlaw / CredentialObjectOneLine.ps1
Created June 28, 2018 11:25
A one line command to get a full (username and password) credential object without bringing them in from variables.
$Credential = New-Object System.Management.Automation.PSCredential 'username',(convertto-securestring 'password' -asplaintext -force)
@AshFlaw
AshFlaw / LogOffRemoteServer.ps1
Created June 18, 2018 18:42
Windows Server Core, closed terminal windows. Remote log off of session so next time, console will launch.
logoff /server:remote_computer_name
@AshFlaw
AshFlaw / ChangeYourADPassword.ps1
Created June 1, 2018 07:38
Change your AD password with PowerShell
$AccountName = ""
Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Current password") -NewPassword (Read-Host -asSecureString "New password")
@AshFlaw
AshFlaw / Invoke-RemoteVolumeExpand.ps1
Created May 14, 2018 13:38
Remotely expand all volumes on a server that have available space.
Function Invoke-RemoteVolumeExpand
{
Param
(
$Server
)
Function Invoke-VolumeExpand
{
$Include = "C|W|D|E|F"
$Partitions = Get-Partition | Where-Object {$_.DriveLetter -Match $Include}
@AshFlaw
AshFlaw / Set-SQLInstanceAllDBLogFileSettings.ps1
Created May 14, 2018 08:10
Function to set the log file initial size and growth values for all databases on an instance to 512MB
Function Set-SQLLogFileSizeAndGrowth
{
Param
(
$Instance
)
Import-Module dbatools -ErrorAction SilentlyContinue
If ((Get-Module | Where-Object {$_.Name -eq "dbatools"}) -eq $null)
{
Write-Output "Installing required module: $dbatools"