Skip to content

Instantly share code, notes, and snippets.


  • The Full Circle
Block or report user

Report or block AshFlaw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
AshFlaw / Invoke-DisconnectedRDPSessionLogOff.ps1
Created Sep 30, 2018
Remotely log off all disconnected sessions from a server, RDP session hosts or otherwise.
View Invoke-DisconnectedRDPSessionLogOff.ps1
$server = ''
$sessions = quser /server:$server | where-object { $_ -match "Disc" }
Foreach ($Session in $Sessions)
$UserName = $Session.split(' +')[1]
$ID = qwinsta /server:$server $UserName | where-object { $_ -match $UserName } | Where { $_ -ne "" } | ForEach { $_.Replace(" ","") } | ForEach { $_.Replace("Disc","") } | ForEach { $_.ToLower() } | ForEach { $_.Replace("$UserName","") }
Write-Output "SessionID $ID Username: $UserName is disconnected"
logoff $ID /server:$server
AshFlaw / Add-OMSNetworkMonitoringFirewallRules.ps1
Created Sep 12, 2018
Bulk add the OMS Log Analytics Network Monitoring rules to all machines in a domain
View Add-OMSNetworkMonitoringFirewallRules.ps1
Function OMSICMPFWRules
netsh advfirewall firewall add rule name="NPMDICMPV4Echo" protocol="icmpv4:8,any" dir=in action=allow
netsh advfirewall firewall add rule name="NPMDICMPV6Echo" protocol="icmpv6:128,any" dir=in action=allow
netsh advfirewall firewall add rule name="NPMDICMPV4DestinationUnreachable" protocol="icmpv4:3,any" dir=in action=allow
netsh advfirewall firewall add rule name="NPMDICMPV6DestinationUnreachable" protocol="icmpv6:1,any" dir=in action=allow
netsh advfirewall firewall add rule name="NPMDICMPV4TimeExceeded" protocol="icmpv4:11,any" dir=in action=allow
netsh advfirewall firewall add rule name="NPMDICMPV6TimeExceeded" protocol="icmpv6:3,any" dir=in action=allow
AshFlaw / install-GPMC.ps1
Created Aug 15, 2018
Install Group Policy Management Console, GPMC via PowerShell
View install-GPMC.ps1
Install-WindowsFeature –Name GPMC
AshFlaw / CopyADGroupMemberships.ps1
Created Jul 19, 2018
Copy AD group memberships from one user account to another.
View CopyADGroupMemberships.ps1
$Source = ""
$Destination = ""
Get-ADUser -Identity $Source -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members $Destination
AshFlaw / EOL-MailBoxAuditing.ps1
Created Jul 19, 2018
Check, enable and disable Tenant level mailbox auditing in Exchange Online
View EOL-MailBoxAuditing.ps1
# 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 / Set-EolMailBoxAuditEnabledAll.ps1
Created Jul 19, 2018
Enable Exchange Online mailbox auditing manually for all mailboxes
View Set-EolMailBoxAuditEnabledAll.ps1
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 / Get-AvailableRAM.ps1
Created Jul 17, 2018
Get available RAM on a remote server via powershell
View Get-AvailableRAM.ps1
$Server = ""
(Get-Counter -Counter "\Memory\Available MBytes" -ComputerName $Server).CounterSamples[0].CookedValue
AshFlaw / CredentialObjectOneLine.ps1
Created Jun 28, 2018
A one line command to get a full (username and password) credential object without bringing them in from variables.
View CredentialObjectOneLine.ps1
$Credential = New-Object System.Management.Automation.PSCredential 'username',(convertto-securestring 'password' -asplaintext -force)
AshFlaw / LogOffRemoteServer.ps1
Created Jun 18, 2018
Windows Server Core, closed terminal windows. Remote log off of session so next time, console will launch.
View LogOffRemoteServer.ps1
logoff /server:remote_computer_name
AshFlaw / ChangeYourADPassword.ps1
Created Jun 1, 2018
Change your AD password with PowerShell
View ChangeYourADPassword.ps1
$AccountName = ""
Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Current password") -NewPassword (Read-Host -asSecureString "New password")
You can’t perform that action at this time.